static void Main(string[] args) { // message m = new message(); account[] arr = new account[3]; arr[0] = new saving("xyz", 30000); arr[1] = new current("pqr", 80000); arr[2] = new saving("lmn", 90000); for (int i = 0; i < 3; i++) { Console.WriteLine(arr[i]); } Console.WriteLine("\n\n"); for (int i = 0; i < 3; i++) { arr[i].ev += (int no, double bal, string name) => { Console.WriteLine("SMS : balance withdraw " + no + " current balance " + bal + " name " + name); }; arr[i].ev += (int no, double bal, string name) => { Console.WriteLine("SMS : balance withdraw " + no + " current balance " + bal + " name " + name); }; } arr[1].deposit(20000); arr[1].withdraw(200); arr[2].deposit(1000); arr[0].withdraw(5000); }
static void Main(string[] args) { account[] arr = new account[3]; try { arr[0] = new saving("xyz", 30000); } catch { Console.WriteLine("inside catch"); } try { arr[1] = new current("pqr", 80000); } catch { Console.WriteLine("inside catch 1"); } arr[2] = new saving("lmn", 90000); for (int i = 0; i < 3; i++) { Console.WriteLine(arr[i]); } Console.WriteLine("\n\n"); arr[1].deposit(20000); arr[1].withdraw(200); arr[2].deposit(1000); try { arr[0].withdraw(29500); } catch { Console.WriteLine("insufficient Balance"); } serial.saveObj(arr, "abc.soap"); serial.getObj("abc.soap"); }
static void Main(string[] args) { account[] arr = new account[3]; arr[0] = new saving("xyz", 30000); arr[1] = new current("pqr", 80000); arr[2] = new saving("lmn", 90000); for (int i = 0; i < 3; i++) { Console.WriteLine(arr[i]); } Console.WriteLine("\n\n"); arr[1].deposit(20000); arr[1].withdraw(200); arr[2].deposit(1000); // arr[2].withdraw(90500); Array.Sort(arr, new udsort()); for (int i = 0; i < 3; i++) { Console.WriteLine(arr[i]); } }