Yan Cui
I help clients go faster for less using serverless technologies.
This article is brought to you by
Don’t reinvent the patterns. Catalyst gives you consistent APIs for messaging, data, and workflow with key microservice patterns like circuit-breakers and retries for free.
In C#, it’s possible to combine two delegates, A and B to create a new multicast delegate, C:
When the multicast delegate is executed, the combined delegates are executed in order as you can see from the example above. But before you can start mix and matching your delegates like a kid in a candy store, there is however, the small matter of having to keep the CLR happy. You see, only delegates of the same type can be combined, but and this is a BIG but, it is a runtime requirement that is not in line with the covariance support in C# 4.
For instance, this is legal in C# 4:
As far as the compiler is concerned this is fine, and it builds and runs, but when you try to invoke the multicast delegate you will get a runtime exception warning you that the delegates must be of the same type..
Whenever you’re ready, here are 3 ways I can help you:
- Production-Ready Serverless: Join 20+ AWS Heroes & Community Builders and 1000+ other students in levelling up your serverless game. This is your one-stop shop for quickly levelling up your serverless skills.
- I help clients launch product ideas, improve their development processes and upskill their teams. If you’d like to work together, then let’s get in touch.
- Join my community on Discord, ask questions, and join the discussion on all things AWS and Serverless.