Say I declared the following classes:
class BaseClass{
public static BaseClass Create(string url){
}
public void Method(){
}
}
class SubClass: BaseClass{
new public void Method(){
}
}
Now in my main method, I would like to do something like:
BaseClass baseClass = BaseClass.Create(url);
if(baseClass.GetType()==typeof(SubClass)){
baseClass.Method();
}
The idea here, of course, is to use Method, as it is implemented in SubClass. This may be a dumb question, but how do I do this? I cannot drop the base class into a subclass, so I'm not sure ...
EDIT
Clarified my question. Despite the fact that baseClass was declared as an instance of BaseClass, it baseClass is SubClasswill return true, if any url, that it Createreturns an instance SubClass.
source
share