/// <summary>
/// 生成随机字符串
/// </summary>
/// <param name="b">是否有复杂字符</param>
/// <param name="c">是否有字母</param>
/// <param name="n">是否有数字</param>
/// <param name="l">生成的字符串长度</param>
/// <returns></returns>
protected string getStr(bool b, bool c, bool n, int l)
{
string str = string.Empty;
if(c) str += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";//字母
if(n) str += "0123456789";//数字
if(b) str += "!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~";//复杂字符
StringBuilder SB = new StringBuilder();
Random rd = new Random();
for(int i = 0; i < l; i++)
{
SB.Append(str.Substring(rd.Next(0, str.Length), 1));
}
return SB.ToString();
}
#endregion
}