Skip to content

Prefer "Count" to "Count()" #489

@giggio

Description

@giggio

If it is an IList or some other object that has Count as a property, don't use the Linq extension method.

So this:

var count = myList.Count();

Becomes:

var count = myList.Count;

Important:
Count and Count() have to return the same type.
Count() has to be an extension method.

Diagnostic id: CC0098
Severity: Warning
Category: Performance

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions