find the keys of a map in csharp

In C#, you can use the Keys property of a Dictionary object to get an enumerable collection of all the keys in the dictionary. Here is an example:

main.cs
Dictionary<string, int> myDictionary = new Dictionary<string, int>();
myDictionary.Add("apple", 2);
myDictionary.Add("banana", 4);
myDictionary.Add("orange", 8);

foreach (string key in myDictionary.Keys)
{
    Console.WriteLine(key);
}
237 chars
10 lines

In this example, the Keys property is used to get a collection of all the keys in the myDictionary object, which are then printed to the console using a foreach loop.

gistlibby LogSnag