/// <summary>
/// 检测字符串中是否有非法的字符,如果有,返回true
/// </summary>
/// <param name="badword">要检查的字符串</param>
/// <returns></returns>
public static bool ChkBadWord(string badword)
{
string[] bw = strbadword();
bool isok = false;
foreach (string str in bw)
{
if (badword.IndexOf(str) > -1)
{
isok = true;
return isok;
}
}
return isok;
}
private static string[] strbadword()
{
string[] bad = new string[16];
bad[0] = "'";
bad[1] = "\"";
bad[2] = ";";
bad[3] = "--";
bad[4] = ",";
bad[5] = "!";
bad[6] = "@";
bad[7] = "#";
bad[8] = "$";
bad[9] = "%";
bad[10] = "^";
bad[11] = "&";
bad[12] = "*";
bad[13] = "-";
bad[14] = "+";
bad[15] = "~";
return bad;
}