I'm running this small test program on .NET 6, Windows 11:
int x = "event:/SFX/Crackling/CracklingLoop".LastIndexOf("/");
if (x == 20)
Console.WriteLine("LastIndexOf ok: " + x);
else
Console.WriteLine("LastIndexOf failed: "+x);
int y= "event:/SFX/Crackling/CracklingLoop".IndexOf("/");
if (y == 6)
Console.WriteLine("IndexOf ok: " + y);
else
Console.WriteLine("IndexOf failed: "+y);
On my computer, it prints the expected values:
LastIndexOf ok: 20
IndexOf ok: 6
However, on the computers of some customers, it prints:
LastIndexOf failed: 34
IndexOf failed: 0
I'm completely baffled how this is possible. When I re-implement string.IndexOf myself, everything works as expected.
There have been changes regarding IndexOf and \n characters (previously discussed here, here and in other places). However, these strings do not contain any \n.