Created
November 26, 2014 13:43
-
-
Save anonymous/c59a113ce5da0913e1f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// What's the output of this code, and how confident are you? | |
// What might affect the result? | |
class Test | |
{ | |
static void Main() | |
{ | |
string stringx = "a"; | |
string\u180ex = "b"; | |
System.Console.WriteLine(stringx); | |
} | |
} |
To my eyes it doesn't look like it compiles!
I'm still trying to find a machine that's sufficiently out of date to make it print "a". That should be a bit of a hint :)
(But both outputs are potentially valid. Arguably, only "a" strictly complies with the C# 5 specification, I believe...)
Ah - made more progress. It should either compile with a result of "b", or it should not compile. The Mono compiler (at least the version I'm using) has a bug where even "string\u0020x" works, but that fails to compile with csc.exe.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should get "b" in the output... I wonder if an Mongolian vowel separator is legal according to the specs though...
EDIT: After some digging: The Mvs is not in the Unicode class 'Zs' which is determined to be a white space according to the C# Language Spec (Grammer section 1.2), it is in the class 'Cf' which is the class described as 'Other, Format'... Since it is not a white space... it is removed.