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).

1 comment:

  1. Hey! thanks for great review. It was easy to read, but I'd like to add that if your business needs to be updated try it outsourcing company.

    ReplyDelete