Is it possible to override or shadow (new in C#) instance methods with extension methods?
+7
A:
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.
Thomas
2009-11-16 22:10:44
I was about to quote the exact same article ;)
Jean Regisser
2009-11-16 22:16:18
+1
A:
@Jean; Exactly.
Also, remember that Extension methods are just syntactic sugar; you're not actually extending the class, just making a static method that takes the class as an argument.
Nate Zaugg
2009-11-16 23:25:11