public static void AttendMeeting(Emp e) { if (e is Programmer) { Programmer p = (Programmer)e; p.Display(); } else if (e is SalesMgr) { SalesMgr s = (SalesMgr)e; s.Display(); } else if (e is Admin) { Admin a = (Admin)e; a.Display(); } }
public static void AttendMeeting1(Emp e) { Programmer p = e as Programmer; if (p != null) { p.Display(); } SalesMgr s = e as SalesMgr; if (s != null) { s.Display(); } Admin a = e as Admin; if (a != null) { a.Display(); } }