public static void Main()
Student s = new Student("Ayushi", 16, 109098);
Student s1 = new Student("Vidhu", 17, 1090561);
Teacher t = new Teacher("Salas", 26, "Pre-Calc");
Person [] list = {p, s, s1, t};
for(int i = 0; i < list.Length; i++)
list[i].DisplayDetails();
public Person(string n, int a)
public virtual void DisplayDetails()
Console.WriteLine("The person's name is " + Name + " and is " + Age + " years old");
public class Student : Person
public Student(string n, int a, int s) : base(n, a)
public override void DisplayDetails()
Console.WriteLine("The student's ID is " + StudentId);
public class Teacher : Person
public Teacher(string n, int a, string s) : base(n, a)
public override void DisplayDetails()
Console.WriteLine("The teacher teaches " + Subject);