What is the output of: string s = “abc”; s.ToUpper(); Console.WriteLine(s);?
Correct answer C. abc in small letters
Strings in C# are immutable: no method changes an existing string object. ToUpper returns a new string with the converted text, but the code ignores that return value, so s still refers to "abc". To keep the result you must assign it, as in s = s.ToUpper();. This immutability is also why repeated concatenation in a loop is better done with StringBuilder.
Answer checked How we write and check questions
Discussion