Skip to content

using IsNullOrWhiteSpace or IsNullOrEmpty in string comparator #695

@julianosaless

Description

@julianosaless

This:

   if(name == "") {}
   if(name == string.Empty) {}
   if(name == null){}   

   if(name != "") {}
   if(name != string.Empty) {}
   if(name != null){}   

Becomes:

   if (string.IsNullOrEmpty(name)) { }
   if (string.IsNullOrEmpty(name)) { }
   if (string.IsNullOrEmpty(name)) { }

or (different code fix)

   if (!string.IsNullOrWhiteSpace(name)) { }
   if (!string.IsNullOrWhiteSpace(name)) { }
   if (!string.IsNullOrWhiteSpace(name)) { }

Category: Refactoring
Id: CC0113
Severity: Hidden

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions