Overriding Extension Methods

前端 未结 9 1279
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 13:57

I\'ve been thinking about using extension methods as a replacement for an abstract base class. The extension methods can provide default functionality, and can be \'overridd

9条回答
  •  失恋的感觉
    2020-12-03 14:14

    This is definitely a bad idea. Extension methods are bound statically which means that, unless your calling the override on an object whose compile-time type is the sub-type, you'll still continue to call the extension method. Bye-bye polymorphism. This page has a good discussion of the perils of extension methods.

提交回复
热议问题