I have SortedList<DateTime, object>
. Each times in it is a KeyValuePair<>
which is a struct. So, how can I understand when method FirstOrDefault
found nothing in this list ?(for classes it returns null
but for a struct
?)
Why I just cant compare default(KeyValuePair<Key, Value>)
and result of FirstOrDefault
?
private SortedList<DateTime, GatewayPassage> gwPassages =
new SortedList<DateTime, GatewayPassage>(new DescDateTimeComparer());
var lastGwPassages = gwPassages.FirstOrDefault(x => x.Value.Tag == tag &&
x.Value.Gateway == gateway);
I want condition like "if found nothing"
if(lastGwPassages == %some kind of default value%)