Posted By

wallybh on 11/02/10


Tagged

list Generic Anonymous c#


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


Anonymous generic List


 / Published in: C#
 

URL: http://kirillosenkov.blogspot.com/2008/01/how-to-create-generic-list-of-anonymous.html

Enables to create a generic list with anonymous types. Very useful for me :).

  1. var Customer1 = new { IdCustomer = 1, FirstName = "Eric", LastName = "Clapton" };
  2. var Customer2 = new { IdCustomer = 2, FirstName = "Kurt", LastName = "Cobain" };
  3. var Customer3 = new { IdCustomer = 3, FirstName = "John", LastName = "Doe" };
  4.  
  5. var customerList = (new[] { Customer1, Customer2, Customer3 }).ToList();

Report this snippet  

You need to login to post a comment.