public void AddUser(string name) { bool userIsBanned = false; foreach (string user in BannedUsers) { if (name == user) { userIsBanned = true; } } if (!userIsBanned) { UserAddedEventArgs args = new UserAddedEventArgs(); args.Name = name; UserAdded(this, args); User newUser = new User(); newUser.Name = name; Users.Add(newUser); } else { UserBannedEventArgs args = new UserBannedEventArgs(); args.Name = name; UserBanned(this, args); } }
static void OnUserAdded(object sender, UserAddedEventArgs args) { Console.WriteLine($"Welcome {args.Name}!"); }