Hi Juan,
one way you could do this is shown below. The code creates a string of
pre-determined length that consists only of the character A-Z:
int stringLength = 10;
Random rnd = new Random((int)System.DateTime.Now.Ticks);
System.Text.StringBuilder randomText = new
System.Text.StringBuilder(stringLength);
//value of A in ascii codes
int minValue = 65;
//value of Z in ascii codes
int maxValue = 90;
//the range that we are allowed to go above the min value
int randomRange = maxValue - minValue;
double rndValue;
for(int i=0; i<stringLength; i++)
{
rndValue = rnd.NextDouble();
randomText.Append((char)(minValue + rndValue * randomRange));
}
Console.WriteLine(randomText.ToString());
Hope that helps
Mark R Dawson
"Juan" wrote:
Hi
How to generate an unique random string of determinate characters length?
Thanks