about random string

  • Thread starter Thread starter miladhatam
  • Start date Start date
M

miladhatam

hi , how can i generate a random string like this "a8t32zx1bg3"
i know that about Number
random.next(x)
does it work without Number ?
thanks
 
hi,
you can get a random number between 1 and 26, and cast it to a char.

public static char GetRandomLowerCaseCharacter(int seed)
{
return ((char) ( (short) 'a' + new Random(seed).Next(26)));
}

public static char GetRandomUpperCaseCharacter(int seed)
{
return ((char) ( (short) 'A' + new Random(seed).Next(26)));
}

even simpler, if you don't mind being restricted to hex characters.... use
Guid.NewGuid()

hope this helps
tim
 
excellent ...
i was thinking .net have a function for this
i admire you for your good intelligence
you answered very soon
thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top