Click here to Skip to main content
15,916,949 members
Home / Discussions / C#
   

C#

 
GeneralRe: Source For C# Pin
3-Feb-01 22:18
suss3-Feb-01 22:18 
GeneralRe: Source For C# Pin
2-May-01 3:38
suss2-May-01 3:38 
GeneralRe: Source For C# Pin
Christian Graus18-Aug-04 16:26
protectorChristian Graus18-Aug-04 16:26 
QuestionWas the cookie accepted? Pin
29-Jan-01 12:16
suss29-Jan-01 12:16 
AnswerRe: Was the cookie accepted? Pin
Mazdak24-Feb-04 5:36
Mazdak24-Feb-04 5:36 
GeneralI am sorry. Just test.. Pin
29-Jan-01 0:06
suss29-Jan-01 0:06 
GeneralRe: I am sorry. Just test.. Pin
Christian Graus18-Aug-04 16:28
protectorChristian Graus18-Aug-04 16:28 
GeneralDelegates Pin
19-Jan-01 11:34
suss19-Jan-01 11:34 
This is to help people understand delegates better in Abdul Azeez's article. (See that article under C# Articles - about delegates and events).

I found a bunch of mistakes in the article. First:

1. In your example for a Single Cast Delegate, you passed a function without an object reference, you created the object too late, and you used "this" in a static function (which is illegal and makes no sense). The correct code is:

TestDelegateClass tdc = new TestDelegateClass();
MyDelegate mdg = new MyDelegate(tdc.MyFunction);
Boolean f = mdg(tdc,1);

2. You state that in a Multi-Cast Delegate, that the MDelegate points to the head of the list. (You even have a diagram showing a delegate with Fn1,2,3,4 and pointing to Fn1) This is impossible. That is how a usual list works, with ".Next". However, the first delegate in the list has no information about the next delegate. If the multicast delegate pointed to #1, and then you "popped" that function off the stack, you'd be left with no reference to #2, as there is only a .prev, and no .next. In fact, if you look in the "locals" window (or "watch" window) you'll find that the Multi-cast delegate points to the last delegate which in turn has a reference in it to the second to last, and so on up the line. So the digram should look like this:

MultiCast Delegate
---------------------

MCDelegate1
MCDelegate2 ^
MyMCDelegate ------> MCDelegate3 ^

Those "up" carrots mean that the delegate is pointing (i.e. holds a ref. to in their "_prev") to the delegate above.

If the MyMCDelegate pointed to MCDelegate1 (which it pops first), then it would have no way of knowing what's next, because it would be pointing to nothing. Further, it wouldn't know when to stop, since there would be no field to say "null" or stop. So instead, MyMCDelegate "walks" up the list (through the "_prev") until it hits a null value in "_prev", and pops them off until it gets back to the head where it started.

Hope this helps!

DM
GeneralRe: Delegates Pin
Christian Graus18-Aug-04 16:29
protectorChristian Graus18-Aug-04 16:29 
GeneralNew C# and ADO.NET article Pin
Griffo18-Jan-01 9:32
Griffo18-Jan-01 9:32 
Generaldistributing C# application Pin
Valentin Rozescu15-Jan-01 0:51
Valentin Rozescu15-Jan-01 0:51 
GeneralRe: distributing C# application Pin
29-Jan-01 4:03
suss29-Jan-01 4:03 
GeneralRe: distributing C# application Pin
Brian Olej28-Feb-03 7:04
Brian Olej28-Feb-03 7:04 
GeneralC# dll Pin
11-Jan-01 12:53
suss11-Jan-01 12:53 
GeneralRe: C# dll Pin
- V -14-Jan-01 17:22
- V -14-Jan-01 17:22 
QuestionWhy is "this.SomeVar" used in C# wont "SomeVar" work? Pin
4-Jan-01 13:35
suss4-Jan-01 13:35 
AnswerRe: Why is "this.SomeVar" used in C# wont "SomeVar" work? Pin
Russell Morris4-Jan-01 14:39
Russell Morris4-Jan-01 14:39 
AnswerRe: Why is Pin
- V -14-Jan-01 17:31
- V -14-Jan-01 17:31 
GeneralPLEASE HELP Me with a simple DOS C problem Pin
14-Dec-00 12:32
suss14-Dec-00 12:32 
GeneralC# and ASP+ Pin
David Hubbard3-Nov-00 8:50
David Hubbard3-Nov-00 8:50 
GeneralRe: C# and ASP+ Pin
23-Nov-00 10:47
suss23-Nov-00 10:47 
GeneralRe: C# and ASP+ Pin
- V -14-Jan-01 17:33
- V -14-Jan-01 17:33 
GeneralUser Interface Pin
Mike18-Sep-00 14:31
Mike18-Sep-00 14:31 
GeneralRe: User Interface Pin
Member 120896513-Oct-00 17:44
Member 120896513-Oct-00 17:44 
GeneralRe: User Interface Pin
- V -14-Jan-01 17:37
- V -14-Jan-01 17:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.