I have the following interface:
public interface Iface
{
void Sample1();
void Sample1(bool value);
}
And the implementation is shown below. Note: It is requried that Sample1’s implementation be explicit (due to generic constraints voodoo)
public class myCLass : Iface
{
void Iface.Sample1()
{
this.Sample1(true);
}
void Iface.Sample1(bool value)
{
}
}
Trying to call the overload, however, results in this error:
Error 5 ‘myCLass’ does not contain a definition for ‘Sample1’ and no extension method ‘Sample1’ accepting a first argument of type ‘myCLass’ could be found (are you missing a using directive or an assembly reference?) Q:\common\VisualStudio\Charting\Drilldowns.cs 18 15 Charting
Bottom line: I think I’m unsure of the syntax I should be using to call the ‘other’ overload in the same interface.
Since you’re implementing the interface explicitly, you need to cast yourself to the interface:
Or, if you don’t like the in-line cast:
If you did a normal, implicit implementation, you’d be able to call the method directly. Explicit interface implementations are only usable on a variable specifically defined as that interface.