Does delegate chaining have to start with a null Delegate?
- by MCS
In CLR via C#, Jeffrey Richter gives the following example of delegate chaining (pg. 406):
internal delegate void Feedback(Int 32 value);
Feedback fb1 = new Feedback(method1); // in the book, these methods
Feedback fb2 = new Feedback(method2); // have different names
Feedback fb3 = new Feedback(method3);
Feedback fbChain = null;
fbChain = (Feedback) Delegate.Combine(fbChain, fb1);
fbChain = (Feedback) Delegate.Combine(fbChain, fb2);
fbChain = (Feedback) Delegate.Combine(fbChain, fb3);
Why does the first call to Delegate.Combine have to pass in a null Delegate? Here's how I would have thought it should be written:
Feedback fbChain = (Feedback) Delegate.Combine(fb1, fb2);
fbChain = (Feedback) Delegate.Combine(fbchain, fb3);