Valerie Meunier

Valerie Meunier

  • NA
  • 693
  • 82.9k

why is string value not changed?

Jun 22 2021 11:00 AM

Hi

string is reference type, so why do i get this with the code below: Joe Joe Bill, Joe?

I would expect Joe Joe Bill, Bill because string is not a value variable.

Thanks again

            string str = "Joe";
            string str2 = str;
            Console.WriteLine(str);
            Console.WriteLine(str2);

            str = "Bill";
            Console.WriteLine(str);
            Console.WriteLine(str2);


Answers (4)