Women in Technology

Hear us Roar



Article:
  A Java Programmer Looks at C# Delegates
Subject:   anonymous inner classes
Date:   2003-05-23 12:08:36
From:   anonymous2
Response to: anonymous inner classes

Delegates actually are bound to a class (although delegates referencing static methods are also possible).
For example, you could have "delegate int CountDelegate()" and then have "new CountDelegate(CounterInstance.CountMethod)". In that case the CounterInstance holds the counter state between delegates calls. This is similar to what an inner class would achieve.


I detail this some more in an article (http://blog.monstuff.com/archives/000037.html) that shows that the delegate holds both an object (state) and a method pointer, and also goes through the implementation details.


Cheers
Dumky