We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here's a small example code to reproduce the issue:
byte[] buf = { (byte)'A', (byte)'B', (byte)'C', (byte)'\0' }; string s = Encoding.ASCII.GetString(buf); Console.WriteLine(s.IndexOf("\0")); /* outputs 0 for .NET 5 and 3 for .NET Core 3.1 */ Console.WriteLine(s.IndexOf('\0')); /* outputs 3 for .NET 5 and 3 for .NET Core 3.1 */
byte[] buf = { (byte)'A', (byte)'B', (byte)'C', (byte)'\0' };
string s = Encoding.ASCII.GetString(buf);
Console.WriteLine(s.IndexOf("\0")); /* outputs 0 for .NET 5 and 3 for .NET Core 3.1 */
Console.WriteLine(s.IndexOf('\0')); /* outputs 3 for .NET 5 and 3 for .NET Core 3.1 */
Ok, it doesn't make much sense to search for "\0" instead of '\0', but the results differ from .NET Core 3.1.
The text was updated successfully, but these errors were encountered:
Tagging subscribers to this area: @tarekgh, @safern, @krwq See info in area-owners.md if you want to be subscribed.
area-System.Globalization, untriaged
area-System.Globalization
untriaged
Sorry, something went wrong.
duplicate of #46569
Looks like this is correct for .NET 5:
https://docs.microsoft.com/en-us/dotnet/standard/base-types/string-comparison-net-5-plus
No branches or pull requests
Here's a small example code to reproduce the issue:
byte[] buf = { (byte)'A', (byte)'B', (byte)'C', (byte)'\0' };
string s = Encoding.ASCII.GetString(buf);
Console.WriteLine(s.IndexOf("\0")); /* outputs 0 for .NET 5 and 3 for .NET Core 3.1 */
Console.WriteLine(s.IndexOf('\0')); /* outputs 3 for .NET 5 and 3 for .NET Core 3.1 */
Ok, it doesn't make much sense to search for "\0" instead of '\0', but the results differ from .NET Core 3.1.
The text was updated successfully, but these errors were encountered: