.Substring
method CS-P1007Index lookup methods such as IndexOf
, LastIndexOf
, IndexOfAny
, and LastIndexOfAny
return the index of the char
depending on the arguments supplied. Chaining such calls to .Substring
requires that a part of the string be selected and then the char be looked up. Instead, consider calling the index lookup methods directly and then subtracting the begin offset.
var c = 'C';
var pos = str.Substring(beg).IndexOf(c);