Showing posts with label Software. Show all posts
Showing posts with label Software. Show all posts

Tuesday, November 23, 2010

C# Anonymous Type

Anonymous types may be most notably being used by the JavaScript community but they have been around C# since .NET 3.0.

Here is an example of how to declare an anonymous type in C#:

var Person = new { FirstName ="Walter", LastName="Soto" }

//Print it to the console
Console.WriteLine(Person.FullName);

The compiler will then create the object at compile type (not at runtime).