Sunday, September 22, 2013

Call a field that contains a delegate in C#!

class Dog : Animal
{
   public Action Woof = () => Console.WriteLine("woof!");
}

 
 

This is more fun from this video and Joe Albahari uses it like so:

dynamic x = new Dog();
x.Woof();

No comments:

Post a Comment