tag:blogger.com,1999:blog-6628985022531866193.post7513686227052933057..comments2024-02-12T17:37:05.629+00:00Comments on The OldWood Thing: Using Extension Methods to Extend A C# InterfaceChris Oldwoodhttp://www.blogger.com/profile/18183909440298909448noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-6628985022531866193.post-61972403378866347552015-09-29T09:10:33.667+01:002015-09-29T09:10:33.667+01:00You can't, if I understand you correctly. An i...You can't, if I understand you correctly. An interface by definition is more generalised than a class and so an extension method based on the interface has to apply to all classes that implement it.<br /><br />If only one class needs the one-parameter overload then only add the method to the concrete class. It sounds to me like the interface probably needs the one-parameter method and the extension method is the no-parameter overload that calls the one-parameter version with a default value.Chris Oldwoodhttps://www.blogger.com/profile/18183909440298909448noreply@blogger.comtag:blogger.com,1999:blog-6628985022531866193.post-26170743044785220182015-09-21T16:56:14.550+01:002015-09-21T16:56:14.550+01:00Hi Chris, i have an interface that has a method wi...Hi Chris, i have an interface that has a method without any parameters and this interface is implemented by two concrete classes, so what i want is to overload this method inside the interface to accept a parameter using an extension method and i want to use it only in one class how can i accomplish that ?<br />Thank you and sorry for my English.azertyhttps://www.blogger.com/profile/02357077893524168354noreply@blogger.com