+ 1
what is the difference between abstract method and virtual method?
I wonder please give me one example of program difference
2 Antworten
+ 1
Hello,
Abstract methods have NO implementation and HAS to be override in sub classes.
Class Vehicle{
Public abstract void drive();
}
Class Car:Vehicle{
Public override void drive(){
Console.WriteLine("driving a Car");
}
}
Virtual methods are already implemented and if you want to change the behavior in a subclass you CAN override it. But you dont have to.
Class Vehicle{
Public virtual void drive()
{
Console.WriteLine("driving a vehicle");
}
}
Class Car:Vehicle{
Public override void drive(){ // this you can do but you dont have to
Console.WriteLine("driving a Car");
}
}
Hope i can help u a little.
0
thank you for giving answer to me