开发者

Override (or shadow) a method with extension method? [duplicate]

开发者 https://www.devze.com 2022-12-11 09:12 出处:网络
This question already has answers here: Closed 9 years ago. Possible Duplicate: Is there any way in C# to override a class开发者_Python百科 method with an extension method?
This question already has answers here: Closed 9 years ago.

Possible Duplicate:

Is there any way in C# to override a class开发者_Python百科 method with an extension method?

Is it possible to override or shadow (new in C#) instance methods with extension methods?


No. From MSDN:

You can use extension methods to extend a class or interface, but not to override them. An extension method with the same name and signature as an interface or class method will never be called. At compile time, extension methods always have lower priority than instance methods defined in the type itself.

0

精彩评论

暂无评论...
验证码 换一张
取 消