Console.WriteLine("Hello".LastIndexOf(""));
Console.WriteLine("Hello".LastIndexOf("", StringComparison.Ordinal));
Console.WriteLine("Hello".AsSpan().LastIndexOf(""));
Console.WriteLine("Hello".AsSpan().LastIndexOf("", StringComparison.Ordinal));
// PRINTS:
// 4
// 4
// 0
// 4
The behavior of ROS<T>.LastIndexOf differs based on whether the char-specific overload is called or whether the generic T overload is called, as shown above. We should make the behavior consistent.
(To be fair, all of these APIs should be returning "5", not "4". I'll file a separate bug for that.)
The behavior of
ROS<T>.LastIndexOfdiffers based on whether thechar-specific overload is called or whether the genericToverload is called, as shown above. We should make the behavior consistent.(To be fair, all of these APIs should be returning "5", not "4". I'll file a separate bug for that.)