I have a function in my form that generates a random string. I want to show the result of this function in both a message box and a text box at the same time. How to? Should my function be public or private?
Here is my function:
public string GenerateRandomCode(int myLength)
{
string charPool = "ABCDEFGOPQRSTUVWXY1234567890ZabcdefghijklmHIJKLMNnopqrstuvwxyz";
StringBuilder rs = new StringBuilder();
Random random = new Random();
for (int i = 0; i < myLength; i++)
{
rs.Append(charPool[(int)(random.NextDouble() * charPool.Length)]);
}
return rs.ToString();
}