public string GenerateName() { int i = 1; while (true) { string name = "User #" + i.ToString(); if (ConnectedUsers.Exists(p => ((User)p).Username == name)) { i++; } else { return(name); } } }