Atulya Panda
How to initialize Dictionary using collection initialize?
By Atulya Panda in ASP.NET on Nov 26 2012
  • Manju lata Yadav
    Jul, 2014 9

    Dictionary students = new Dictionary() {{ 111, new StudentName {FirstName="Sachin", LastName="Karnik", ID=211}},{ 112, new StudentName {FirstName="Dina", LastName="Salimzianova", ID=317}},{ 113, new StudentName {FirstName="Andy", LastName="Ruth", ID=198}} };The innermost braces enclose the object initializer for the StudentName, and the outermost braces enclose the initializer for the key/value pair that will be added to the students Dictionary. Finally, the whole collection initializer for the dictionary is enclosed in braces.

    • 0
  • keerthi rakasi
    Feb, 2013 28

    it will store values in key/value pair.And the syntax is Dictionary obj=new Dictionary(); obj.Add(1,"jan"); obj.Add(2,"feb");

    • 0
  • Atulya Panda
    Nov, 2012 26

    Dictionary t = new Dictionary() { {1, “a”}, {2, “vb”}, {3, “c”}};

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS