How to convert dictionary to list in

Using below example we can convert the dictionary to list in

        static void Main(string[] args)
            //convert dictionary to list
            Dictionary<int, string> empDictionary = new Dictionary<int, string>();
            empDictionary[1] = "Ranga";
            empDictionary[2] = "Rajesh";

            //convert dictionary to list
            List<KeyValuePair<int, string>> empList = new List<KeyValuePair<int, string>>();
            empList = empDictionary.ToList();

            foreach(var data in empList)
                Console.Write("key:"+ data.Key);
                Console.WriteLine("   value:"+data.Value);



If you have any queries or suggestions, please feel free to ask in comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar