I have an object of the type IEnumerable, I am using
var getResult= keyValueList.SingleOrDefault()
I recommend more understanding way using extension method:
public static class KeyValuePairExtensions
{
public static bool IsNull(this KeyValuePair pair)
{
return pair.Equals(new KeyValuePair());
}
}
And then just use:
var countries = new Dictionary
{
{"cz", "prague"},
{"de", "berlin"}
};
var country = countries.FirstOrDefault(x => x.Key == "en");
if(country.IsNull()){
}