PC Review


Reply
Thread Tools Rate Thread

delegate object as an argument

 
 
James
Guest
Posts: n/a
 
      29th Oct 2008
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.
 
Reply With Quote
 
 
 
 
Family Tree Mike
Guest
Posts: n/a
 
      29th Oct 2008
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).

"James" <(E-Mail Removed)> wrote in message
news:3baa3c5f-48b2-4afc-ac6f-(E-Mail Removed)...
> 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.


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable Argument Generic Delegate Advait Mohan Raut Microsoft C# .NET 4 22nd Sep 2008 08:10 AM
Is there any predefined delegate with no argument? Dancefire Microsoft Dot NET Framework 1 9th Nov 2007 07:56 AM
Delegate as argument (C++/CLI) vijay.gandhi@gmail.com Microsoft VC .NET 3 18th May 2007 07:09 PM
Passing Event Delegate as an argument Kerry Jenkins Microsoft VB .NET 1 15th Jun 2004 03:13 AM
Callback Method Delegate as an Argument to Dll Functions John Bowman Microsoft C# .NET 10 24th Dec 2003 05:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:06 AM.