Skip to main content
1 of 6
Timwi
  • 13k
  • 3
  • 46
  • 66

C# (199 chars)

It was quite a challenge to do this in C# because the restrictions preclude any use of quite a lot of the common keywords. It is possible in C# to use \uxxxx Unicode escape sequences in identifiers, but unfortunately not in keywords.

using System;struct a{static object b;static int Main(){object[]c={"\u0048e\u006c\u006co "+(C\u0068ar)(86+1)+"or\u006c\u0064"};typeof(Conso\u006ce).GetMet\u0068o\u0064s()[101].Invoke(b,c);return 0;}} 

Explanation:

// I won’t be able to get anywhere without using “System”. // Even if I write it as “Syst\u0065m”, it still violates rule 2. // Therefore, that is the rule we’ll violate. using System; // Thus, we can’t use: H L W D 2 7 // We can’t write “class”, so the Main type must be a struct. struct a { // We can’t write “null”, so declare a static field that defaults to null. static object b; // We can’t write “void”, so Main needs to return an int. static int Main() { // We can’t write “new”, but we can instantiate an array // using the initialisation syntax. object[] c = { "\u0048e\u006c\u006co " + (C\u0068ar) (86 + 1) + "or\u006c\u0064" }; // We can use the character escape sequence to write “Console”, // but not “Write” because W is \u0057, which contains a 7. // Therefore, we have to use Reflection to get it. typeof(Conso\u006ce).GetMet\u0068o\u0064s()[101].Invoke(b, c); // Since Main returns int, we have to return something. return 0; } } 
Timwi
  • 13k
  • 3
  • 46
  • 66