示例#1
0
文件: Event.cs 项目: theojin/cs
        //static void Main()
        //{
        //    Stock stock = new Stock("THPW");
        //    stock.Price = 27.10M;
        //    stock.PriceChanged += stock_PriceChanged;
        //    stock.Price = 31.59M;
        //}

        static void stock_PriceChanged(object sender, PriceChangedEventArgs e)
        {
            if ((e.NewPrice - e.LastPrice) / e.LastPrice > 0.1M)
            {
                Console.WriteLine("Alert, 10% stock price increase!");
            }
        }
示例#2
0
文件: Event.cs 项目: theojin/cs
 protected virtual void OnPriceChanged(PriceChangedEventArgs e)
 {
     PriceChanged?.Invoke(this, e);
 }