IEnumerable doesn't have a Count method

后端 未结 4 529
一整个雨季
一整个雨季 2020-11-27 19:06

I have the following method:

public bool IsValid
{
  get { return (GetRuleViolations().Count() == 0); }
}

public IEnumerable GetRuleVio         


        
4条回答
  •  失恋的感觉
    2020-11-27 19:20

    IEnumeration does not have a method called Count(). It's just a kind of "sequence of elements". Use for example List if you explicitly need the number of elements. If you use Linq keep in mind, that the extension method Count() may actually re-count the number of elements each time you call it.

提交回复
热议问题