To find the key associated with a specific value in a Dictionary (which is the C# equivalent of a map), you can use LINQ to search for the first key that has the desired value:
main.cs369 chars13 lines
In the above example, the FirstOrDefault method of the Dictionary is used with a lambda expression to search for the first key-value pair where the value is equal to 2. The Key property of that pair is then returned. If no matching key is found, null is returned.
gistlibby LogSnag