This sounds a little bit like some homework assignment but here goes.
This method will make a random string of a given length out of small and
capital letters using ascii A-Z, a-z,
private string GenerateString(int length)
{
Random rand = new Random();
string randomString = "";
for(int i = 0; i < length; i++)
{
int small = rand.Next(2);
int letter = rand.Next(26);
if(small == 0)
letter += 65;
else
letter += 97;
randomString += Convert.ToChar(letter);
}
return randomString;
}
If your objective is to get something irregular and/or unique you could use
System.Guid.NewGuid.ToString()
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.