Puzzle
Write a C# program which
- compiles without errors or warnings under some set of compiler options;
- contains the following sequence of characters: ?>?>[,])??(()=>{;}),},}]<<=!(~+-*++
- does not contain any string literals or comments
- it doesn't have to do anything useful
Solution
My solution requires the /unsafe compiler switch to be set.
using System;
public class Experiment
{
// This must be "struct", otherwise it's not nullable
public struct G { }
// This must be "Action" to be compatible with ()=>{;}
public class X { public Action x; }
// This needs a getter and setter for <<= to be applicable
public int this[X[] t] { get { return 47; } set { } }
// This needs to be marked 'unsafe' in order to use pointer types
public unsafe void Blah()
{
byte b = 5;
// This needs to be of a pointer type for the unary '*' operator to be applicable
byte* a = &b;
// This is the magic line!
this[new[] { new X { x = (Action) (object) default(G?>[,])??(()=>{;}),},}]<<=!(~+-*++a > 0) ? 0 : 0;
}
// It needs a Main method, otherwise it doesn't compile
public static void Main() { }
}