5
Reply

How can i generate different unique string in different length

anjumathi kumar

anjumathi kumar

Jun 23 2011 6:18 AM
1.9k
{
public static string createRandomString(int Length)string _allowedChars = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ";Random randNum = new Random();int outputLength = (int)(randNum.NextDouble() * Length); //<<<<<<<<< moved out of loop

char[] chars = new char[outputLength]; //<<<<<<<< use outputLength here

// not used int allowedCharCount = _allowedChars.Length;

{
chars[i] = _allowedChars[(
}


}
for (int i = 0; i < outputLength; i++)int)((_allowedChars.Length) * randNum.NextDouble())];return new string(chars);

Hi,

This code generates same string some time and different string some time

this is random generate code function.

how can i change if i want different string in different length always?

Answers (5)