1

On .Net Framework, "0".StartsWith("\x1d") evaluates to false. (fiddle)

On .Net Core 7, "0".StartsWith("\x1d") evaluates to true. (fiddle)

Why?!

Note: Yes, I understand I can use string.StartsWith(char) or string.StartsWith(string, StringComparison.Ordinal) to avoid this. I'm asking why this code changed in behavior.

Mitch
  • 21,223
  • 6
  • 63
  • 86
  • 1
    Likely due to [this](https://learn.microsoft.com/dotnet/standard/base-types/string-comparison-net-5-plus). In short, Framework and Core use different logic for localized string comparison. A control character like `\x1d` is considered empty by one for purposes of comparison, not empty by the other. – Jeroen Mostert Apr 19 '23 at 17:23

0 Answers0