22 March 2010

Totally forgot about references.




class Program
{
static void Main(string[] args)
{
Program p = new Program();

string s = null;

EventHandler<EventArgs> closure = null;

closure =
(o, e) =>
{
Console.WriteLine(s);
p.provemattwrong -= closure;
};

p.provemattwrong += closure;
s = "FUCK";

p.provemattwrong(p, EventArgs.Empty);

}
public event EventHandler<EventArgs> provemattwrong;
}


Needless to say I didn't prove Matt wrong because I forgot that C#'s Refereces reference a Pointer are not Pointers to the object themselves. I feel like a moron.

Labels: ,