Virtual function in Asp.Net :-
If method is define as a virtual method in base class then we can allow the derived class to override that method.
Example of Virtual Method in .Net:
Class parent
{
virtual void hello()
{ Console.WriteLine(“Hello from Parent”); }
}
Class child : parent
{
override void hello()
{ Console.WriteLine(“Hello from Child”); }
}
static void main()
{
parent objParent = new child();
objParent.hello();
}
//Output
Hello from Child.
No comments:
Post a Comment