/// <summary>
/// 此函数将产生12~20位的随机用户名
/// </summary>
/// <param name="length">输入12-20之间的数字</param>
/// <returns>此函数将产生12~20位的随机用户名,返回string类型</returns>
public void GetRandomString(int length)
{
Random rd = new Random();
byte[] str = new byte[length];
int i;
for (i = 0; i < length; i++)
{
int a = 0;
while (!((a >= 48 && a <= 57) || (a >= 97 && a <= 122)))
{
a = rd.Next(48, 122);
}
str[i] = (byte)a;
}
string username = new string(UnicodeEncoding.ASCII.GetChars(str));
this.register = username;
}
/// 此函数将产生12~20位的随机用户名
/// </summary>
/// <param name="length">输入12-20之间的数字</param>
/// <returns>此函数将产生12~20位的随机用户名,返回string类型</returns>
public void GetRandomString(int length)
{
Random rd = new Random();
byte[] str = new byte[length];
int i;
for (i = 0; i < length; i++)
{
int a = 0;
while (!((a >= 48 && a <= 57) || (a >= 97 && a <= 122)))
{
a = rd.Next(48, 122);
}
str[i] = (byte)a;
}
string username = new string(UnicodeEncoding.ASCII.GetChars(str));
this.register = username;
}