Zum Inhalt springen

Linq count misuse (ARCH902)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key dotnet.linq.linq-count-misuse · Severity info · Category linq

Using Count() > 0 just to check for existence counts the whole collection; Any() stops at the first element.

if (users.Count() > 0)
{
Process(users);
}
if (users.Any())
{
Process(users);
}

Use Any() for existence checks.