Can I use interface method instead of delegate? How? I found searching that interface method is faster than using delegates. I would appreciate a simple code snippet.
+4
A:
In theory, it's possible to accomplish everything done by delegates with interfaces (Java has no delegates, for instance) containing a single method. However, it makes the code more verbose and adds little benefit. Then again, it's possible to do everything without classes and possibly do it faster. That doesn't mean you should avoid using classes. Calling a delegate method might be marginally slower than calling an interface method. You shouldn't care about the micro-optimization. Use whatever fits your specific need.
Mehrdad Afshari
2010-01-06 10:04:40