c# Extension methods - design patterns

后端 未结 10 3217
予麋鹿
予麋鹿 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 17:02

    They are not based on an existing design pattern. When this 'feature' was first introduced in Delphi, under the name 'class helpers', Borland even warned users away from them. They were considered a bit of a hack, but now the dust has settled they have found a place of their own.

    Like everything else, use when appropriate.

提交回复
热议问题