how to generate a random string, and specify the length you want, or better generate unique string on specification you want

Posted by HCP on Stack Overflow See other posts from Stack Overflow or by HCP
Published on 2011-01-06T15:43:03Z Indexed on 2011/01/06 15:53 UTC
Read the original article Hit count: 154

Filed under:
|

There is a library to generate Random numbers, so why in't there a library for generation random strings ?

In other words how to generate a random string, and specify the length you want, or better generate unique string on specification you want i.e specify the length, a unique string within my application is enough for me.

I know I can create a Guid (globally unique identifier) but those are quite long, longer they need to be.

int length = 8;
string s = RandomString.NextRandomString(length)
uniquestringCollection = new UniquestringsCollection(length)
string s2 = uniquestringCollection.GetNext();

© Stack Overflow or respective owner

Related posts about c#

Related posts about string