Sunday, February 16, 2014

Anonymous Types in C#

On run time, If you want to keep key/value pair data other than typed class or generic class.
You can use the "Anonymous Type" in C# language.
It’s useful when it’s conjugate with LINQ.

var myClass = new {ClassName="SPList",NameSpace="Microsoft.SharePoint"};

new operator without any class name.
You can access the attribute value as usual,
myClass.ClassName and myClass.NameSpace