c# - Can I retrieve the interface type within an interface method? -
how can determine underlying interface method dosomething()
called? additional question: can determine underlying interface in myclass constructor? assume not not known @ instantiation time, correct?
edit: not looking explicit interface implementations different way determine underlying interface.
public interface itest { void dosomething(); //....more methods } public interface idecoy { void dosomething(); //...more methods } public class myclass : itest, idecoy { public void dosomething() { //question: how can determine underlying interface called method? //at 1 time itest, @ idecoy. how can figure out 1 @ each time? } } public class test { public test() { itest myclassinstance1 = new myclass(); idecoy myclassinstance2 = new myclass(); myclassinstance1.dosomething(); myclassinstance2.dosomething(); } }
public class myclass : itest, idecoy { void itest.dosomething() { //called itest } void idecoy.dosomething() { //called idecoy } }
Comments
Post a Comment