Question by
GraveHag · Feb 24, 2019 at 03:31 PM ·
listif statementgenerator
Random name Generator - duplicity name
Ahoy,
I try to figure out how to remove or do not get a duplicate name.
I have this:
private string[] NewName = new string[] {"Alan","Albert","Birc", "Baad", ............... };
private List<string> NameList = new List<string>(); //List for adding new names for checking duplicity.
public string NameGenerator()
{
int pickName = Random.Range(0, NewName.Length);
name = NewName[pickName];
NameList.Add(name); //Add name to the List
return name;
}
I need to add something like: If NameList contains duplicate names, then...
Thank you for your response. G.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612192353im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Delete duplicates in a list of vectors 1 Answer
How to get tooltips to pop up on certain levels, but not all of them 2 Answers
List Null Ref 1 Answer
Problem with List.Addrange 1 Answer