In the console application, several objects are created that are subscribed to the event. We need to find out for which objects the event handler worked and display their name. For this, I decided to create a list and a method that adds signed events to this list. But it is not the names that are displayed, but the "assembly_name" .Person.
List<Person> allPersons = new List<Person>(); public void AddPersonToOffice(Person person) { if (allPersons.Contains(person)) return; allPersons.Add(person); this.EmpoyerComeIn += person.IsComing; foreach (var all in allPersons) { Console.WriteLine(all); }
Console.WriteLine(all.Name);
- IgorPerson
, which is not contained in the list ofallPersons
. - IgorallPersons
list areallPersons
. Try it. - Igor