Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / October 2007

Tip: Looking for answers? Try searching our database.

Can we declare delegates in class and can we declare delegates in Interface

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bhuwan Bhaskar - 02 Oct 2007 19:22 GMT
Hello,

Can we declare delegates in the class? Can we declare delegates in interface
?

Warm Regards,

Bhuwan
Edgar Harris - 02 Oct 2007 20:11 GMT
Yes and no.  The thing to remember about delegates is they are in themselves
classes that inherit from System.Delegate.  Since nested classes are allowed
in classes you my declare a delegate in a class.  For example the following
is legal:

public class MyClass
{
  public delegate void MyDelegate();
}

To reference that delegate outside of MyClass you would write the following:

MyClass.MyDelegate myDel;

Since a delegate is a type that inherits from delegate you cannot declare a
delegate within an interface, because you cannot declare nested types in an
interface.  That being said I tend to declare my delegates outside of a class
and inside a namespace, because like I said delegates really are just classes.

> Hello,
>
[quoted text clipped - 4 lines]
>
> Bhuwan
Bhuwan Bhaskar - 03 Oct 2007 04:07 GMT
Thnaks Edgar,

Can we declare delegates inside Interface.

Regards,
Bhuwan

> Yes and no.  The thing to remember about delegates is they are in
> themselves
[quoted text clipped - 32 lines]
>>
>> Bhuwan
Göran Andersson - 03 Oct 2007 09:14 GMT
> Thnaks Edgar,
>
> Can we declare delegates inside Interface.
>
> Regards,
> Bhuwan

Edgar already answered that:

"Since a delegate is a type that inherits from delegate you cannot
declare a delegate within an interface".

>> Yes and no.  The thing to remember about delegates is they are in
>> themselves
[quoted text clipped - 32 lines]
>>>
>>> Bhuwan

Signature

Göran Andersson
_____
http://www.guffa.com

Bhuwan Bhaskar - 04 Oct 2007 05:25 GMT
Thanks ! Göran Andersson.

Regards,
Bhuwan
>> Thnaks Edgar,
>>
[quoted text clipped - 44 lines]
>>>>
>>>> Bhuwan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.