Hi there,
I have a list, which I am adding to during the running of a for(). As i go thru this for loop, I want to check the list to see if any value, int, already exists. I believe I need to use the Contains() but I can not figure out how to apply it to my circumstance.
for(int i = 0; i < nmbrFE; i++){
rdnmInt = Random.Range(0, dbInGroup.Length);
///NOW, before I add this rdmInt to the list,
//....I must see if it already exists in the list. ???
///if(rdmInt does not exist already in list… add)
groupMembersUsedLsit.Add(rdmInt);
}
Not really a Unity question but - Contains returns a bool, so check if Contains is false and if so add to the list. Alternately, depending on your use case, use a HashSet.