From what I know, you still need to instantiate the "body" of an interface in order to run correctly. For example, if you have an interface that looks like this:
public interface IResponse
{
string GetResponse();
}
and the method calling the interface like so:
public TestCall(IResponse r)
{
MessageBox.Show(r.GetResponse());
}
so when you call the method, the parameter has to be "instantiated" at some point, I can not just pass in an empty IResponse
.
Whether it's in the Main Program or another class, it does not matter.
But what if I do NOT know the name of the inherited class before compiling?
Such as, I made 2 extensions dll both inherited from IResponse
, for simplicity sack let's just call it A:IResponse
and B:Iresponse
, and user A decides to plug in A
, user B decides to plug in B
?
I can't do IResponse A = new A();
since A
does not exist in user B's app, and vice versa.
So how can I make a foolproof way to instantiate whichever dll the users had chosen to plug in?
Much appreciated!