I am strugling with getting the index of sequence "\a\b" in string. Any idea how to do it? I am doing following:
string expr = "Hello\a\b";
Console.WriteLine(expr.IndexOf("\a\b"));
This code returns 0 instead of expected 5
string expr = "Hello\a\b";
var inx = expr.IndexOf("\a\b", StringComparison.Ordinal);
Refer to documentation https://learn.microsoft.com/en-us/dotnet/api/System.StringComparison?view=net-6.0
\a(alert) and\b(backspace), then yes, that duplicate is wrong for you and the accepted answer is correct. However, not only these characters are rather unusual in a string, you are also explicitly saying in the title of the question that you want to search for the backslash character, for which that duplicate is correct.