ToUpper() method not working

前端 未结 6 858
星月不相逢
星月不相逢 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:15

    A System.String is immutable, so you must re-assign, like:

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

    All methods that manipulate strings, leave the original string unchanged and returns a new string with the desired content. You must pick up that return value and assign it to something.

提交回复
热议问题