C#


ROSLYN.PERFORMANCE.CA1836 : Prefer IsEmpty over Count (C#)

See Roslyn-Detected C# Warning Classes for more information.

Summary

For determining whether the object contains or not any items, prefer using 'IsEmpty' property rather than retrieving the number of items from the 'Count' property and comparing it to 0 or 1.

This check corresponds to Roslyn rule CA1836. For full rule details, see the Microsoft website: CA1836.

Properties

Class Name Prefer IsEmpty over Count (C#)
Significance reliability
Mnemonic ROSLYN.PERFORMANCE.CA1836
Categories None
Availability Available for C# only.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Prefer IsEmpty over Count (C#)"

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.