hi i am trying to understand this para from the mcad textbook
When a member is overridden, the new member is called in place of the member
in the base class. This is true regardless of the context in which the
member is called.
this is what i want to create an example of.
"For example, if an instance of an inherited class is cast to its base class
and an overridden method is called, the new implementation will be executed,
even though the variable is of the base class type. The type of the object,
not the variable, determines which member is called. "
I created 2 classes and would like to call the "method" to depict the para
above.
public class Class1
{
public Class1()
{
}
public virtual string method()
{
String s = "calls old method";
return s;
}
}
public class Class2: Class1
{
public Class2()
{
}
public override string method()
{
String s = "calls new method";
return s;
}
}
but i dont know how to call the "method" so that i can understand what this
para says..
any help would be great..
thanx