Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
603 views
in Technique[技术] by (71.8m points)

c# - ToUpper() method not working

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() method. But, when I add a breakpoint and go through the line, my string is not getting converted into Upper case. strObject variable will always contain the text Task_status. I wish to convert it into TASK_STATUS. Am I missing anything? Posting my relevant code below:-

public void VerifyValue(String strObject, String strValue, int row)
        {               
            strObject.ToUpper().Trim();
            strValue.ToUpper().Trim();
            switch (strObject)
            {
                case "TASK_STATUS":
                    if (m_taskStatus.taskStatus.ToString() == strValue)
                    {
                        ExcelRecorder(null, row);
                    }
                    else
                    {
                        ExcelRecorder("The value [" + m_taskStatus.taskStatus.ToString() + "] does not match with the given value.", row);
                    }
            }
        }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

strObject.ToUpper() returns a string in upper case

Use the following ...

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...