//public static void Main() //{ // Action method = Add; // method(); // // Console.WriteLine(method()); // Console.ReadKey(); // Stock stock = new Stock("MSFT"); // stock.Price = 120; // stock.PriceChanged += stock_PriceChanged; // stock.Price = 135; //} public static void stock_PriceChanged(object sender, PriceChangedEventArgs e) { if ((e.NewPrice - e.LastPrice) / e.LastPrice > 0.1M) { Console.WriteLine("Alert, 10% stock price increase."); } }
protected virtual void OnPriceChanged(PriceChangedEventArgs e) { PriceChanged?.Invoke(this, e); }