lundi 18 janvier 2021

The name 'random' does not exist in the current context" error in Unity

I'm trying to generate random string of letters and numbers but I keep getting this error of the enumerable but now that I solved it it appears ("The name 'random' does not exist in the current context"). I have this code:

private static string RandomString(int length)
{
    const string pool = "abcdefghijklmnopqrstuvwxyz0123456789";
    var chars = Enumerable.Range(0, length)
        .Select(x => pool[random.Next(0, pool.Length)]);
    return new string(chars.ToArray());
}



Aucun commentaire:

Enregistrer un commentaire