Today, I encountered a problem when I changed the bug. Multiple methods were registered to an event, and these methods were mutually exclusive. As a result, I found a bug, I was so depressed that I reviewed my previous knowledge and made some proper extensions. I recorded and shared my achievements to prevent them from being committed again.
Obviously, this is a delegated chain. First of all, let's review the initial Writing Method of the delegated chain. Here we reference N writing methods of the previous delegate. Which one do you like? .
Define delegation:
PlusStringHandle( x, y);
plusString( x, x +
PlusStringHandle handle = +=+= str = handle(, , handle.Method.Name);
TestString (x, x + y +
PlusStringHandle handle = +=+=+=-=-= str = handle(, , handle.Method.Name);
Continue to modify the Main method:
PlusStringHandle handle = +=+=+= handle = testString; str = handle(, , handle.Method.Name);
=================================================== ==================
Next, we will continue to discuss the returned values obtained by the delegate chain. As described above, directly calling the delegate can only obtain the returned values of the last registered method, there are two methods to obtain the returned values of all registered methods:
PlusStringHandle handle = +=+=+= str = handle(, = (PlusStringHandle d , d.Method.Name, d(, (Delegate d Console.WriteLine(, d.Method.Name, d.DynamicInvoke(,