Instantiating objects with C# delegates

This is a common pattern in the options/config space. Both methods have some advantage and disadvantage

  • DoStuffOneWay: passing a delegate allows the underlying system to instantiate the actual object however it likes, it also allows the underlying system to apply your options repeatedly

  • DoStuffOtherWay: Allows you to pass your options object from whichever system you like, and fully control the lifecycle of these objects.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top