If ClassDHO
implements InterfaceDHO
as follows:
class ClassDHO : InterfaceDHO
{
void InterfaceDHO.METHODHERE(arg1, arg2) ...
}
then METHODHERE
is what's termed an explicit interface implementation, and it can only be accessed via a variable of type InterfaceDHO
. The code you show is a little long-winded, but handles that situation. It could be simplied to the following though:
InterfaceDHO in1 = new ClassDHO();
in1.METHODHERE(ARG HERE, ARG2 HERE);
However, if this is not the case, then the following code will, at least for the small snippet you provide, have the same affect:
var in1 = new ClassDHO(); // in1 will be of type ClassDHO
in1.METHODHERE(ARG HERE, ARG2 HERE);
In other words, the interface variable isn't required.
You provide very little code though and in1
may be used in other ways later in the code (or you may have missed bits out), so it's not possible to say for sure.
ClassDHO
implemented? That is are there interface methods there that are implemented asInterfaceDHO.<some method>
(aka Explicit Interface Implementation)?