Hi,
I have a scenario as given below.
Class A
{
public void method()
{
Console.WriteLine("A");
}
}
Class B :A
{
public void method()
{
Console.WriteLine("B");
}
}
Here in main method of a class, I create an object for Class B and I want to access method() of Class A.
i.e B b = new B(); Using this 'b' object I want to access the method() of Class A.
I am unable to do this please give me the solution
Access Parent class method using child class object
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Oct 15, 2011, 8:47 AM EDT
((A)b).method();
Sam HobbsRank #108 · 20.5K reputationPosted Oct 15, 2011, 4:21 PM EDT