Pattern: Missing use of string.Method(char)
Issue: -
string.Method(string)
is used when string.Method(char)
was available.
The target methods on string for these rules:
- StartsWith
- EndsWith
- IndexOf
- LastIndexOf
The following table summarizes the conditions for each of the related rule IDs.
Example of incorrect code:
public bool StartsWithLetterI()
{
var testString = "I am a test string.";
return testString.StartsWith("I");
}
Example of correct code:
public bool StartsWithLetterI()
{
var testString = "I am a test string.";
return testString.StartsWith('I');
}