Interview Questions

How do I create a Delegate/MulticastDelegate?

C# Interview Questions and Answers


(Continued from previous question...)

136. How do I create a Delegate/MulticastDelegate?

C# requires only a single parameter for delegates: the method address. Unlike other languages, where the programmer must specify an object reference and the method to invoke, C# can infer both pieces of information by just specifying the method's name. For example, let's use System.Threading.ThreadStart: Foo MyFoo = new Foo(); ThreadStart del = new ThreadStart(MyFoo.Baz); This means that delegates can invoke static class methods and instance methods with the exact same syntax!

(Continued on next question...)

Other Interview Questions