Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I am doing webtest where I need to use a name as a parameter. But the name should be unique for each webtest.It should not be a normal name like mathew or john. It should be something like ahrjakajrdkj and then next time it should be different from ahrjakajrdkj. It can be ahrjakajrdkji or something like that (but different from the first one). I am using C sharp as the code base. Please help

Thanks,
D
Posted

Use the Random class to generate a length. The length could be something bound by some arbitrary lengths like 2 and 32. Then use a StringBuilder and the same Random object to create a random string of characters.
 
Share this answer
 
v2
Can't you somehow create a GUID and then convert it to string? It will not be like "ahrjakajrdkj" but will probably be unique.

For creating GUIDs:
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=335
 
Share this answer
 
v2
Use a Guid - guaranteed to be unique every time.

EDIT ==========

Ooops - someone already suggested it...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900