O'Reilly logo

.NET Framework 4.5 Expert Programming Cookbook by A.P. Rajshekhar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accessing JSON using dynamic programming

In Version 3.5, .NET introduced the var keyword. With var, developers got the choice of not declaring the type of the variable. It became the task of the compiler to infer the type of the variable based on the value assigned. .NET 4.0 took this concept a step ahead by introducing the keyword dynamic.

When a variable is declared dynamic, its type is inferred only during execution. The compiler does not check for the type and type safety of a dynamic variable. This helps a lot when dealing with data whose type is either unknown or too complex to be bound to a compiled object. In this recipe, you will see how dynamic can access parsed JSON data without creating classes for the JSON elements. One thing to keep ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required