ToDictionary : ToDictionary : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » ToDictionary »

 

ToDictionary








    
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass {
    public static void Main() {
        var scoreRecords = new[] { new {Name = "A", Score = 50},
                                new {Name = "B" , Score = 40},
                                new {Name = "C", Score = 45}
                              };
        var scoreRecordsDict = scoreRecords.ToDictionary(sr => sr.Name);
        Console.WriteLine("Bob's score: {0}", scoreRecordsDict["Bob"]);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» ToDictionary