Cover Page by Eric Lippert, Mark Michaelis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

12. Delegates and Lambda Expressions

Previous chapters discussed extensively how to create classes to encapsulate data and operations on data. As you create more and more classes, you see common patterns in the relationships among them. One common pattern is to pass an object to a method solely so that the method can in turn call a method on the object. For example, if you pass to a method a reference to IComparer<int>, odds are good that the called method will itself call the Compare() method on the object you provided. In this case, the interface is nothing more than a way to pass a reference to a single method that can be invoked. It seems unnecessary to have to define a new interface every time you want to pass a method around. In this chapter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required