Last active
December 23, 2015 19:29
-
-
Save RANUX/6683463 to your computer and use it in GitHub Desktop.
C# Extend Dictionary to find Key by Value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DictionaryUtils | |
{ | |
public static string FindKey(this IDictionary<string, string> lookup, string value) | |
{ | |
foreach (var pair in lookup) | |
{ | |
if (pair.Value == value) | |
return pair.Key; | |
} | |
return ""; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment