c# - Calling base class methods with interface reference variable -


i have base class , interface. creating subclass these. if create reference variable of interface type point object of child class, can access base class methods using it?

class baseclass { public void baseclassmethod() { ..... } }   interface myinterface { public void interfacemethod(); }   class childclass:baseclass, myinterface { ....  }   ....   main() { myinterface myclass= new childclass (); myclass.baseclassmethod();//is possible? y?  } 

the variable myclass statically typed myinterface, not have method called baseclassmethod() - no, won't work. need cast reference baseclasss or child (either fine), or add method myinterface (or additional interface).


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -