unity create random string

Code Example - unity create random string

                
                        string RandomStringGenerator(int lenght)
    {
        string characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
        string generated_string = "";

        for(int i = 0; i < lenght; i++)
            generated_string += characters[Random.Range(0, lenght)];

        return generated_string;
    }
                    
                
 

unity random string

                        
                                string RandomStringGenerator(int lenght)
    {
        //string st = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        string result = "";
        for (int i = 0; i < lenght; i++)
        {
            char c = (char)('A' + Random.Range(0, 26));
            result += c;
        }

        return result;
    }
                            
                        
 

Related code examples