C#


ROSLYN.PERFORMANCE.CA1820 : Test for empty strings using string length (C#)

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

Summary

Comparing strings by using the String.Length property or the String.IsNullOrEmpty method is significantly faster than using Equals.

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

Properties

Class Name Test for empty strings using string length (C#)
Significance reliability
Mnemonic ROSLYN.PERFORMANCE.CA1820
Categories None
Availability Available for C# only.
Enabling Checks for this warning class are disabled by default. To enable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="Test for empty strings using string length (C#)"

Relevant Configuration File Parameters

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