Retuns defaultValue if Key is not found in the dictionary Else returns value for the key

Posted by Niladri.Biswas under C# category on | Points: 40 | Views : 995
public static object GetDBValue<TKey, TSource>(this IDictionary<TKey, TSource> dict, TKey key, object defaultValue)
if (dict.ContainsKey(key))
return dict[key];
return defaultValue;

Comments or Responses

Login to post response