using System.Collections.Generic;
public static void Main()
List<Students> StudentData = new List<Students>
new Students{ID= 101,Name = "Sony", Marks = 780},
new Students{ID = 102, Name = "Rohan", Marks = 890},
new Students{ID=103,Name = "Shiva", Marks = 896}
Dictionary<int,string> results = StudentData.ToDictionary(x => x.ID, x=> x.Name);
Console.WriteLine("Converting List of items to Dictionary");
foreach(KeyValuePair<int,string> d in results)
Console.WriteLine(d.Key + " " + d.Value);
Dictionary<int,Students> sresult = StudentData.ToDictionary(x => x.ID);
Console.WriteLine("Converting whole student class as a dictionationay value...");
foreach(KeyValuePair<int,Students> d in sresult)
Console.WriteLine(d.Key + " " + d.Value.Name + " " + d.Value.Marks);
int[] Numbers = new int[]{12,34,45,67,56,23,43,21,10};
List<int> numresult = Numbers.Where(x => x>20).ToList();
Console.WriteLine("Converting data to List");
foreach(int n in numresult)
public string Name{get;set;}
public int Marks{get;set;}