日期:2014-05-18  浏览次数:20529 次

ASP.NET的一个简单问题
string   Dept=Convert.ToString(cmd.ExecuteScalar());
if(Dept.ToString()== "人事 ")
{
        Response.Write( "OK ");
}
备注:cmd.ExecuteScalar()的返回值为:人事
我已经用Response.write(Dept)打印过。。结果为:人事

问题:为何下面的比较语句不相等,不能打印OK出黎。。十分感谢

------解决方案--------------------
string Dept=cmd.ExecuteScalar().ToString().Trim();
if(Dept == "人事 ")
{
Response.Write( "OK ");
}

------解决方案--------------------
string Dept=cmd.ExecuteScalar().ToString().Trim();
if(Dept == "人事 ")
{
Response.Write( "OK ");
}