ToUpper() method not working

前端 未结 6 857
星月不相逢
星月不相逢 2021-01-20 09:52

I am passing a message from a server that gets stored into a string variable called strObject. I wish to convert the string inside strObject to upper case. So, I use ToUpper

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-20 10:26

    This won't work since strings are immutable, you have to assign the value back to strObject

    strObject = strObject.ToUpper().Trim();
    

    Also there is nothing much done by the switch as shown in your code, you can remove it unless this is not the entire code.

    public void VerifyValue(String strObject, String strValue, int row)
    {               
         //strObject.ToUpper().Trim();
         //strValue.ToUpper().Trim();
         if(strObject.ToUpper() ==  "TASK_STATUS")
         {
              if (m_taskStatus.taskStatus.ToString() == strValue.ToUpper())
              {
                  ExcelRecorder(null, row);
              }
              else
              {
                   ExcelRecorder("The value [" + m_taskStatus.taskStatus.ToString() + "] does not match with the given value.", row);
               }
           }
    }
    

提交回复
热议问题