The requested page is not available for the requested platform. You are viewing the content for Default platform.
All docs
V19.1
19.1
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

CRR0051 - String.IsNullOrEmpty can be used

This analyzer identifies expressions that test a string for null (Nothing in Visual Basic) or an empty value, which can be replaced with a string.IsNullOrEmpty method call.

public bool AddRecord(string name, object data) {
    if (name == null || name == string.Empty || data == null)
        return false;
    //...
    return true;
}

To fix this issue, use the string.IsNullOrEmpty method call instead of logical expressions:

public bool AddRecord(string name, object data) {
    if (string.IsNullOrEmpty(name) || data == null)
       return false;
    //...
    return true;
}

Call the Use string.IsNullOrEmpty refactoring to replace the logical expression with the string.IsNullOrEmpty method call.