Article View: borland.public.csharpbuilder.language.csharp
Article #239Re: event versus simple delegate
From: Francois PIETTE [ICS - MidWare]
Date: Sat, 29 Jul 2006 18:27
Date: Sat, 29 Jul 2006 18:27
53 lines
2445 bytes
2445 bytes
I was speaking about C# v1 which has a slightly different syntax.
Can you explain what difference there is (C# V1) declaring an event member
using the event keyword and declaring a member which is simply a delegate ?
--
francois.piette@overbyte.be
The author for the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be
"Joanna Carter [TeamB]" <joanna@not.for.spam> a �crit dans le message de
news: 44cb81eb@newsgroups.borland.com...
> "Francois PIETTE [ICS - MidWare]" <francois.piette@overbyte.be> a �crit
> dans
> le message de news: 44cb7da5$1@newsgroups.borland.com...
>
> | Porting to C#, I can create C# events corresponding to Delphi events.
> But
> | those C# events will of course be unicast only.
>
> Not necessarily :-) .C# delegates are always multicast, but you can assign
> only one handler if you wish.
>
> public delegate void TestHandler(int value);
>
> {
> private void HandleTest(int value)
> {
> // handler code
> }
>
> private TestHandler test;
>
> private void CallTest()
> {
> test = HandleTest; singlecast
> test(123);
> test += HandleTest; // now multicast
> }
> }
>
> You can see that both assigning (singlecast) and += (multicast) are both
> available.
>
> Joanna
>
> --
> Joanna Carter [TeamB]
> Consultant Software Engineer
>
>
Technical Details
Message-ID:
<44cba8c5@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news2.volia.net!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!news.albasani.net!reader.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mailReferences:
<44cb7da5$1@newsgroups.borland.com> <44cb81eb@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,62beb5b391211bf0 X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII From: "Francois PIETTE [ICS - MidWare]" <francois.piette@overbyte.be> Newsgroups: borland.public.csharpbuilder.language.csharp References: <44cb7da5$1@newsgroups.borland.com> <44cb81eb@newsgroups.borland.com> Subject: Re: event versus simple delegate Date: Sat, 29 Jul 2006 20:27:01 +0200 Lines: 55 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 81.244.49.158 Message-ID: <44cba8c5@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1154197701 81.244.49.158 (29 Jul 2006 11:28:21 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news2.volia.net!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!news.albasani.net!reader.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail