O'Reilly logo

.NET Common Language Runtime Unleashed by Kevin Burton

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

Comparing delegates

delegates can be compared. A delegate overrides the equality operator (==) and the (!=) operator. These two operators in turn rely on the Equals method that is an overridden method for the delegate class. Similar to the way strings can be compared by value and not by reference, the Delegate class compares the value of the delegate rather than the reference. For a delegate, the value consists of the values exposed by the Method and Target properties seen in Listings 14.5 and 14.8. If the Method and Target properties are the same, then the delegates are considered to be equal. Two different instances will obviously have different Targets, so delegates defined on different instances will be considered different. In addition, ...

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