By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,857 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,857 IT Pros & Developers. It's quick & easy.

about random string

P: n/a
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

Jan 18 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

Jan 18 '07 #2

P: n/a
excellent ...
i was thinking .net have a function for this
i admire you for your good intelligence
you answered very soon
thanks

Jan 18 '07 #3

P: n/a
yes it took me a while to figure out too!
glad to help
<mi********@gmail.comwrote in message
news:11**********************@v45g2000cwv.googlegr oups.com...
excellent ...
i was thinking .net have a function for this
i admire you for your good intelligence
you answered very soon
thanks
Jan 18 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.