Skip to content

Instantly share code, notes, and snippets.

Created November 26, 2014 13:43
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/c59a113ce5da0913e1f9 to your computer and use it in GitHub Desktop.
Save anonymous/c59a113ce5da0913e1f9 to your computer and use it in GitHub Desktop.
// 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);
}
}
@aydjay
Copy link

aydjay commented Nov 26, 2014

To my eyes it doesn't look like it compiles!

@jskeet
Copy link

jskeet commented Nov 26, 2014

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...)

@jskeet
Copy link

jskeet commented Nov 27, 2014

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