How to get the list of keys in a dictionary with C#

1 Answer

0 votes
using System;
using System.Collections.Generic;

namespace ConsoleApplication_C_Sharp
{
    static class Program
    {
        static void Main()
        {
            var dic = new Dictionary<string, int>();
            dic.Add("vb.net", 9);
            dic.Add("java", 6);
            dic.Add("php", 7);
            dic.Add("python", 3);
            dic.Add("c#", 4);

            foreach (string key in dic.Keys) {
                Console.WriteLine(key);
            }
        }
    }
}


/*
run:
   
vb.net
java
php
python
c#
    
*/

 



answered Oct 17, 2018 by avibootz

Related questions

1 answer 194 views
1 answer 158 views
1 answer 176 views
176 views asked Oct 17, 2018 by avibootz
1 answer 168 views
168 views asked Aug 3, 2018 by avibootz
1 answer 208 views
...