delegate object as an argument

J

James

Hello,

I tried to pass a delegate object to a function, it works fine if the
access modifier is private but gives me a compile error when the
access modifier of the function is public. Can anyone explain why ?
ex:
class
{
delegate int testdelegate(int temp) ;
public void testfunction1(testdelegate test, int temp) //gives
errror
{ }
private void testfunction2(testdelegate test,int temp) //works fine
{ }
static void Main()
{ }
}

Thanks,
James.
 
F

Family Tree Mike

testdelegate needs to be declared public if you use it in a public method.
The caller has to know about the delegate in order to use the method
(testfunction1).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top