登录时,验证码不区分大小写进行验证 || 字符串比较时不区分大小写

string showCode = "验证码字符串"
string writeCode = "要输入的字符串";
if (showCode.Equals(writeCode, StringComparison.OrdinalIgnoreCase))
{
    Response.Write("验证码输入成功!");
}
else
{
    Response.Write("验证码输入失败!");
}

 

2.去除字符串中的空格,回车,换行符,制表符

string strResult = str.Replace("\n", "").Replace(" ","").Replace("\t","").Replace("\r","");

 

posted @ 2022-02-22 11:42  驼七  阅读(60)  评论(0)    收藏  举报