private static void PersonTester(IPerson person) { if (person is Teacher2) { Teacher2 t = person as Teacher2; } else if (person is Student1) { Student1 t = person as Student1; } }
static void Main(string[] args) { Student _std = new Student(); _std.Student_Info(); // Teacher1 t_1 = new Teacher1(); Teacher1 t_1 = new Teacher2(); //another advantage of inheritance of class t_1.Teacher_Info(); //show info of Teacher2 class // Teacher2 t_2 = new Teacher2(); // t_2.Teacher_Info(); List <Person> ppp = new List <Person>();//for catch the value of the above list ppp = Employee.Get_Person_Details(); foreach (Person data in ppp) { Console.WriteLine("Employee Id : {0},Employee Name : {1}", data.NID, data.Name); } Console.ReadLine(); }