public mag_C_dbOperation(string strServiceName, string strLsUserID, string strPWD)  //构造函数,数据库连接成功时,保存 连接信息
        {
            strConnectionString = "Server=" + strServiceName + ";User ID=" + strLsUserID + ";Password=" + strPWD;
            strUserID = strLsUserID.ToUpper();            if (OpenConnect())
            {
                strNowInstallType = BackNowInstallationType().Trim().ToUpper(); 
                isNowRunInStation = (strNowInstallType == "STATION" ? true : false);   
                isNowRunInProvinceCenter = (strNowInstallType == "AREA" ? true : false);    
                isNowRunInNationCenter = (strNowInstallType == "NATION" ? true : false);    
                isNowRunInAcademyCenter = (strNowInstallType == "ACADEMY" ? true : false);                      isAllowWriteData = isNowRunInStation || isNowRunInProvinceCenter ? true : false;  
                if (isNowRunInAcademyCenter && strUserID == "GEOMAG")   
                    isAllowWriteData = true;                CloseConnect();
            }
        }
 strUserID = strLsUserID.ToUpper();中ToUpper()是啥意思?
isNowRunInAcademyCenter = (strNowInstallType == "ACADEMY" ? true : false); 是啥意思?     

解决方案 »

  1.   

    strUserID = strLsUserID.ToUpper();中ToUpper()是将strLsUserID的值全部转为大写的意思,如"tim"  .ToUpper后会变成"TIM"isNowRunInAcademyCenter = (strNowInstallType == "ACADEMY" ? true : false); 
    等价于:
    if( strNowInstallType == "ACADEMY" )
    {
      isNowRunInAcademyCenter =true;
    }
    else isNowRunInAcademyCenter  =false;其实这句还可以优化一下:
    isNowRunInAcademyCenter = (strNowInstallType == "ACADEMY"); 
      

  2.   

    你就不会查帮助啊,ToUpper转大写
    isNowRunInAcademyCenter = (strNowInstallType == "ACADEMY" ? true : false); 这是三目运算,等同于if (strNowInstallType == "ACADEMY")
    isNowRunInAcademyCenter = true;
    else
    isNowRunInAcademyCenter = false;
      

  3.   

    ToUpper() 是把strLsUserID转成大写吧
      

  4.   


    strNowInstallType = BackNowInstallationType().Trim().ToUpper();  这句是啥意思?
      

  5.   


    Trim()方法是清除字符串后面的空格,比如“abc  ”,使用Trim()方法后就变为了“abc".
    ToUpper()方法是将所有字符转换为大写,比如 “abc”,用ToUpper()方法处理之后就变为"ABC"
      

  6.   

    BackNowInstallationType()没看到实现,不知道功能,但返回肯定是个字符串
    Trim()去掉两遍的空格
    ToUpper()转为大写你先查msdn吧...