Skip to content

Instantly share code, notes, and snippets.

@RANUX
Last active December 23, 2015 19:29
Show Gist options
  • Save RANUX/6683463 to your computer and use it in GitHub Desktop.
Save RANUX/6683463 to your computer and use it in GitHub Desktop.
C# Extend Dictionary to find Key by Value
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