0

I'm trying to create a script where the user can make inputfields and the add data to it and a other screen the name will be randomized on every click you do.

public void StoreName()
{
    foreach (var input in inputFields)
    {
        string name = input.GetComponent<InputField>().text;
        names.Add(name);
    }
    string result = "";
    foreach (string name in names)
    {
        result += name + "\n";
    }
    textDisplay.GetComponent<Text>().text = result;

}
vimuth
  • 5,064
  • 33
  • 79
  • 116

1 Answers1

0

you can use this method to generate a random string with a specific length

public static string RandomString(int length)
{
    const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    return new string(Enumerable.Repeat(chars, length)
              .Select(s => s[random.Next(s.Length)]).ToArray());
}

this may be useful for more informations

How can I generate random alphanumeric strings?