c# Extension methods - design patterns

后端 未结 10 3488
予麋鹿
予麋鹿 2021-02-20 16:33

I would like to know if C# extension method is based on any existing design pattern.

10条回答
  •  礼貌的吻别
    2021-02-20 16:57

    The extension methods can be thought as a replacement of the Visitor Pattern. It is also proposed that they can be used as Adapters.

    In general languages evolve to make the need of design patterns less necessary. There is a quote for example that Lisp doesn't need design patterns, because everything is built in the language. So the right question will be, what design patterns do extension methods replace?

提交回复
热议问题