string.Contains
instead of comparing the result of string.IndexOf
CS-R1110The method string::IndexOf()
returns the index of the character/substring in a string. If no such character/substring exists, -1 is returned. However, the expression string.IndexOf(arg) > -1
effectively checks if arg
exists within a string
and is equivalent to string.Contains(arg)
. Consider rewriting it that way instead to make the intent clearer.
var exists = name.IndexOf('a') > -1;
var exists = name.Contains('a');