Saturday, June 11, 2011

What is Anonymous Type in C#?

O/P

Code description:

var runtimeClass=new {ID=1,Name="Bimlesh"};

In this above line we store the object of class in a variable of type var and create the class with new key word without having a hardcoded class name.

Like any other class we can access the properties of Anonymous class by its object .

runtimeClass.Id=1;

runtimeClass.Name="Bimlesh";

No comments: