-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethodOverriding.cs
More file actions
44 lines (33 loc) · 874 Bytes
/
MethodOverriding.cs
File metadata and controls
44 lines (33 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Diagnostics;
namespace TestApplication
{
/* Polymorphism --- Example of Method Overriding ---
When derived class has a definition for one of the member functions of
the base class. that base function is said to be overriden.
*/
public class Vehicle
{
public virtual void show()
{
Console.WriteLine("Base Class");
}
}
public class Honda : Vehicle
{
public override void show()
{
Console.WriteLine("Derived Class");
}
}
internal static class Polymorphism
{
public static void Main(string[] args)
{
var vehicle = new Vehicle();
vehicle.show();
vehicle = new Honda();
vehicle.show();
}
}
}