2012-04-17 11 views

risposta

44

Enumerable.Count è un metodo di estensione, non una proprietà. Ciò significa che usp_GetLst restituisce probabilmente IEnumerable<T> (o alcuni equivalenti) anziché un derivato di IList<T> o ICollection<T> che ci si aspettava.

// Notice we use lst.Count() instead of lst.Count 
if (lst.Count() == 0) 
{ 

} 

// However lst.Count() may walk the entire enumeration, depending on its 
// implementation. Instead favor Any() when testing for the presence 
// or absence of members in some enumeration. 
if (!lst.Any()) 
{ 

} 
+0

+1 per la raccomandazione "Qualsiasi()". – devgeezer

Problemi correlati