+ 1

what is the difference between abstract method and virtual method?

I wonder please give me one example of program difference

20th Sep 2016, 1:50 AM
venkata veerendra manikumar kancharla
venkata veerendra manikumar kancharla - avatar
2 Answers
+ 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.
21st Sep 2016, 7:00 AM
Minickyi
0
thank you for giving answer to me
21st Sep 2016, 4:36 PM
venkata veerendra manikumar kancharla
venkata veerendra manikumar kancharla - avatar