public VetoEventArgs Vote(string proposal) { VetoEventArgs result = new VetoEventArgs(proposal); OnVote?.Invoke(this, result); return(result); }
static void Main() { VetoComission comission = new VetoComission(); for (int i = 0; i < 5; ++i) { VetoVoter voter = new VetoVoter(GenerateNamePart() + " " + GenerateNamePart()); comission.OnVote += voter.VoteHandler; } Console.WriteLine("Type in your proposal:"); VetoEventArgs result = comission.Vote(Console.ReadLine()); Console.WriteLine((result.VetoBy == null) ? $"The proposal \"{result.Proposal}\" wasn't rejected" : $"The proposal \"{result.Proposal}\" was rejected by spokesman {result.VetoBy.Name})"); }