Anonymous generic List


/ Published in: C#
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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();

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.