/// <summary> /// 類別方法 /// </summary> public void Shout() { Console.WriteLine($"{name}:喵"); //if (CatShout != null) //{ // CatShout(); //} // 執行 CatShout() 等同上面 CatShout?.Invoke(); if (CatShout2 != null) { CatShoutEventArgs2 e = new CatShoutEventArgs2(); e.Name = name; CatShout2(this, e); } CatShout3?.Invoke(name); }
/// <summary> /// 事件处理方法 /// </summary> /// <param name="shoutsound">叫声</param> protected virtual void OnCatShout(string shoutsound) { //#.1.8.3 this 引用 CatShout?.Invoke(this, shoutsound); }