Tuesday, May 24, 2011

IEnumerable of Anonymous types ..

Here's how you create an IEnumerable of an Anonymous type.  This is very useful for talking to JSON

// create anonymous type
var reportExample = new { ReportName = "", ReportID = 0};

// create IEnumerable of anon type
var listExample = (new[] { reportExample }).ToList();

var theList = JsonConvert.DeserializeAnonymousType(hdnSelectedReportIds.Value, listExample);

No comments:

Post a Comment