delegate object as an argument

  • Thread starter Thread starter James
  • Start date Start date
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.
 
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).
 
Back
Top