コード例 #1
0
 /// <summary>
 /// Find a key by it's value in a dictionary.
 /// </summary>
 /// <param name="dictionaryToSearch">
 /// The dictionary whose key you wish to find with the value.
 /// </param>
 /// <param name="value">
 /// The value to use in the search.
 /// </param>
 /// <returns>
 /// Returns the key associated with the value provided, if it exists. If it does not exist, the default will be returned.
 /// </returns>
 public static T AtValue <T>(this System.Collections.Generic.Dictionary <T, string> dictionaryToSearch, string value)
 {
     return(dictionaryToSearch.FirstOrDefault(name => name.Value.Contains(value, StringComparison.OrdinalIgnoreCase)).Key);
 }