Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0050 Implicitly-typed Arrays in Object Initializers

In the following example, contacts is an implicitly-typed array of anonymous types. The var keyword is not used inside the object initializers. public class MainClass { public static void Main() { var a = new[] { new { Name = "C#", ISBNs = new[] { "1-111555-08", "2-222222-01" } }, new { Name = "Java", ISBNs= new[] { "3-333650-55" } } }; } }