how to call base class method in case of virtual orerride ?

Posted by Sonu.pinghal under C# on 9/2/2011 | Points: 10 | Views : 1801 | Status : [Member] | Replies : 2
public class Class1
{
public virtual void hello()
{
Console.write("Hello Base Class");
}
}

public class Class2 : Class1
{
public override void hello()
{
Console.write("Hello Derived Class");
}
}

I know about the Base Keyword. but the BASE keyword work only within Derived class only . can we call " hello()" method of the base class in some other way. If we can then plz. help me ?

Sonu Pinghal


Responses

Posted by: Dhirendra on: 9/2/2011 [Member] Starter | Points: 25

Up
0
Down
just create an instance of Class1 and call hello.
Class1() obj=new Class1 ()
obj.hello()

Sonu.pinghal, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sonu.pinghal on: 9/3/2011 [Member] Starter | Points: 25

Up
0
Down
thanx.

Sonu Pinghal

Sonu.pinghal, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response