MCQs > IT & Programming > C# > Consider the following code: string s1 = 'Old Value'; string s2 = s1; s1 = 'New Value'; Console.WriteLine(s2); What will be the output printed, and why?

C# MCQs

Consider the following code:

        string s1 = "Old Value";

        string s2 = s1;

        s1 = "New Value";

        Console.WriteLine(s2);

What will be the output printed, and why?

Answer

Correct Answer: "Old Value", because string is a reference type which is treated as a special case by the assignment operator.

Explanation:

Note: This Question is unanswered, help us to find answer for this one

C# Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

C# Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it