private string GenerateRandomString(int size)
{
Random r = new Random();
string legalChars = "1234567890";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < size; i++)
sb.Append(legalChars.Substring(r.Next(0, legalChars.Length - 1), 1));
return sb.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(GenerateRandomString(6));
}