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
Post a Comment