Dictionary <int,string> sports; sports=new Dictionary<int,string>(); sports.add(0,"Cricket"); sports.add(1,"Hockey"); sports.add(2,"Badminton"); sports.add(3,"Tennis"); sports.add(4,"Chess"); sports.add(5,"Football"); foreach(var spr in sports) console.WriteLine("Keu {0} and value {1}",spr.key,spr.value);
output:
Key 0 and value Cricket Key 1 and value Hockey Key 2 and value Badminton Key 3 and value Tennis Key 4 and value Chess Key 5 and value Football
source share