Only a 'Static' method can be called using delegate - True / False? Give Reason

Showing Answers 1 - 4 of 4 Answers

factpandit

  • Dec 12th, 2007
 

I think the answer is "false".

Delegate is a type just like a class or a structure.

So, any number of methods that have similar format (return type and parameters) but with differet names as that of a delegate type, can all be treated as objects of a delgate type (Of course delegates are nothing but function pointers).

Their scope and visibility won't matter. For the matter of fact, even a private method of an object oA of a class A that is passed as a delegate to another object oB of class B, can be called with out any compile or run time problem. So this can be treated as a work around for accessing of private methods of an object from a different type object.

Does this make sense?

Cheers :)
FP

  Was this answer useful?  Yes

Naveen Shivanadri

  • Sep 18th, 2016
 

Using delegate, we can execute static method as well as instance method. By binding a method with delegate, we will use the instance if the method is instance method else method name if the method is static.

Naveen

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions