public static void command(object sender, MyListEventArgs args) { int [] arr = args.Arr; Console.WriteLine("sender object: " + sender); // MyList tempList = (MyList) sender; Console.WriteLine("StrategySortMethod run command with name: " + args.name); int temp; for (int j = 0; j <= arr.Length - 2; j++) { for (int i = 0; i <= arr.Length - 2; i++) { if (arr[i] > arr[i + 1]) { temp = arr[i + 1]; arr[i + 1] = arr[i]; arr[i] = temp; } } } foreach (int i in arr) { System.Console.Write("{0} ", i); } Console.WriteLine(""); }
public void RaiseEvent(int[] arr) { MyListEventArgs args = new MyListEventArgs(); args.Arr = this.arr; // Publisher this.strategy(this, args); }
public void Display() { MyListEventArgs args = new MyListEventArgs(); args.Arr = this.arr; args.name = "Nguyen Van A"; // Publisher this.strategy(this, args); }
public static void command(object sender, MyListEventArgs args) { int [] arr = args.Arr; Console.WriteLine("StrategyEvenMethod run command with name: " + args.name); foreach (int i in arr) { if (i % 2 == 0) { System.Console.Write("{0} ", i); } } Console.WriteLine(""); }