Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Possible Duplicate:
Is there any way in C# to override a class method with an extension method?

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

like image 293
Shimmy Weitzhandler Avatar asked Nov 16 '09 22:11

Shimmy Weitzhandler


1 Answers

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.

like image 85
Thomas Avatar answered Nov 13 '22 07:11

Thomas