i want to check my collection so i can add a new customer as long as the username does not exist in the collection i do not want 2 customers to be able to have the same username
i have been trying many different things to try to get this to work but i am not exactly sure what i should be doing I have a aspforum and collection C# class of the list
here is some things that i have tried
CustomerExists() i also have a collection of List<Customers>
//HERE IS MY EXISTS METHOD
public static Boolean IfCustomerExists(string login)
{
List<Customer> theGuy = Collections.Customers;
bool exist = false;
foreach (Customer customer in theGuy)
{
if (customer.UserName == login)
{
exist = true;
break;
}
}
return exist;
}
//THIS IS MY FORUM TRYING TO ADD CUSTOMER TO COLLECTION IF ALL IS WELL
if(customer.UserName != CustomerOptions.IfCustomerExists(Collections.Customers))
{
Collections.Customers.Add(customer);
}