I gave a spur of the moment talk tonight at the San Diego .NET Developers Group. The summary of the talk was this:
A delegate is a type-safe and verifyable pointer to one (or more blocks) of code.
An event is nothing more than a private delegate with public add and remove methods.
An anonymous delegate is a delegate that is defined inline inside another block of code and has no name. It can capture variables according to normal scoping rules.
Then in the piece de resistance I showed a demo that I had first seen given by Anders Heilsberg in a Lang.NET 2008 talk:

http://langnetsymposium.com/2008/talks/1-01%20-%20CSharp3%20-%20Anders%20Hejlsberg.html.

The part I was demo’ing starts at about 14:50.

Here he (as I did in my demo) transforms a anonymous method into a lambda expression:
delegate(Type t) { return t.IsInterface; }
(Type t) => { return t.IsInterface; }
(Type t) => t.IsInterface
(t) => t.IsInterface
t => t.IsInterface

No comments yet.

No Comments »

You must be logged in to post a comment.