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.

CRR0050 - String.Compare can be used

This analyzer identifies string comparison expressions which can be replaced with a string.Compare call to improve code readability and provide comparison options.

bool CheckError(string msg) {
    if (msg.Substring(1, 4) == "Error")
        return true;
    return false;
}

To fix this issue, use the string.Compare method call instead of the "==" ("=" in Visual Basic) or "!=" operator ("<>" in Visual Basic):

bool CheckError(string msg) {
    if (string.Compare(msg.Substring(1, 4), "Error", false) == 0)
        return true;
    return false;
}

Call the Use string.Compare refactoring to convert the comparison with the equality operator or inequality operator to a comparison with the string.Compare method.