I have a 3rd party C++ DLL that I call from C#.
The methods are static.
I want to abstract it out to do some unit testing so I created an interface with the static methods in it but now my program errors with:
The modifier 'static' is not valid for this item
MyMethod cannot be accessed with an instance reference; qualify it with a type name instead
How can I achieve this abstraction?
My code looks like this
private IInterfaceWithStaticMethods MyInterface;
public MyClass(IInterfaceWithStaticMethods myInterface)
{
this.MyInterface = myInterface;
}
public void MyMethod()
{
MyInterface.StaticMethod();
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…