anjumathi kumar

anjumathi kumar

  • NA
  • 54
  • 64.2k

How can i generate different unique string in different length

Jun 23 2011 6:18 AM
{
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)