public void Remove(object obj, int v) { Student st = obj as Student; Tok tk = obj as Tok; if (st != null) { st.RemoveSalary(v); return; } if (tk != null) { tk.RemoveSalary(v); return; } throw new Exception("Not valid obj"); }
static void Main(string[] args) { Director dir = new Director(); Student st = new Student("StudName", 50000); Tok tk = new Tok("TokName", 40000); tk.Up += ShowMsg; tk.Down += ShowMsg; st.Up += ShowMsg; dir.Add(tk, 5000); dir.Add(st, 300); dir.Remove(tk, 100); dir.Remove(st, 500); //========================= Func <string, string, int, string> op = Process; Console.WriteLine(op("qweqweqweqweqweqwe", "ccccc", 10)); }