When I run the following code in .NET Core 3.1, I get 6 as the return value.
// .NET Core 3.1
string s = "Hello\r\nworld!";
int idx = s.IndexOf("\n");
Console.WriteLine(idx);
Result:
6
But when I run this code in .NET 5.0, I get a different result. Why does this happen?
// .NET 5.0
string s = "Hello\r\nworld!";
int idx = s.IndexOf("\n");
Console.WriteLine(idx);
Result:
-1