I have a code:
var fullist = Enumerable.Where<CooldownRecord>(GetCooldowns(petskills), s => (spellId.Contains((uint)s.SpellId) || (SharedIds.Contains((uint)s.SharedId) && s.SharedId != 0)) && s.TimeLeft > 0);
if(fullist.Count() == 0) return 0;
return fullist.Max(s => s.TimeLeft);
Most of the time it works. But sometimes it throws InvalidOperationException on fullist.Max. What am I doing wrong here? How can the fullist be empty if there is a check if(fullist.Count() == 0) return 0; ?