//default of bark
        public void speak(string whatToSay = "bark")
        {
            //TODO...
            //only raise event if event is not null
            HasSpoken?.Invoke(this, EventArgs.Empty);

            /*
             * simplified version of this
             *  if(HasSpoken != null)
             * HasSpoken(this, EventArgs.Empty);
             */
        }
示例#2
0
 // Method signature = scope + return type + name + parameter types
 public void Speak(string what = "bark")
 {
     // If no subscribers are registered to handle event, null reference exception is thrown.
     HasSpoken?.Invoke(this, EventArgs.Empty);
 }