ASP.NET Hosting

Cryptic C#

Does this code compile?

class @class
{
  public int
\u0069n\u0074 = 0;
  public string @public = @"Cryptic C#";
}

class \u0043 : \u0063\u006C\u0061\u0073\u0073 {}

string @string()
{
  @class ç = new @class();
  return new
C().@public+ç.@int;
}

Sure it does.
Actually this is useful if you need to interact with other languages were string or int are not keyword for example. You can find more about this in the C# language specifications, (also available on the C# team page)

3 Comments

  • Heh, cool :)



    When languages support unicode things can get really nice... ever seen a Hebrew method name? :)

  • No, it doesn't!



    The class \u0043 : \u0063\u006C\u0061\u0073\u0073 contains no implementation, so the following piece of code would be directly placed into the namespace, what is not allowed!

    If you close the cruely bracket after the whole code, the code would be ok:



    class \u0043 : \u0063\u006C\u0061\u0073\u0073 {

    string @string()

    {

    @class ç = new @class();

    return new C().@public+ç.@int;

    }

    }

  • Good point GP! :-)

    This code was not directly taken from a namespace, but from another class. In which case it works.

Comments have been disabled for this content.