Skip to content
New issue

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

String IndexOf method return different results on mac an windows #6248

Closed
fujihara opened this issue Jul 1, 2016 · 3 comments
Closed

String IndexOf method return different results on mac an windows #6248

fujihara opened this issue Jul 1, 2016 · 3 comments
Assignees
Milestone

Comments

@fujihara
Copy link

fujihara commented Jul 1, 2016

IndexOf method of string class is returning different results on macOs and Windows.

This issue started after .NET Core release update.

var str = "The quick brown fox jumps over the lazy dog\r\n";
if (str.IndexOf("\n") >= 0) {
    Console.WriteLine("OK");
}
else {
    Console.WriteLine("BAD");
}

On Windows machine it always print:
OK

On Mac it prints:
BAD

I fixed my code passing a char to IndexOf instead string:
if (str.IndexOf('\n') >= 0)

But would be better if both platform to work consistently.

Thanks

PS: I had posted this issue on core repository (dotnet/core#193)

@ghost
Copy link

ghost commented Jul 1, 2016

@stephentoub
Copy link
Member

@danmoseley
Copy link
Member

I agree it seems to be dotnet/corefx#4587. Please see explanation there

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the 2.0.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants