-5

Example:

String Str1="Hello";

String Str2=Str1;

Str1="Welcome";

Console.Writeline(Str1); //output is Welcome

Console.Writeline(Str2); //output is Hello

if String is reference type, then Str2 value should come as Welcome right?

Thanks.

Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321
Kumar
  • 1
  • 1

1 Answers1

0

Make a little change then Str2 would come Welcome try this.

String Str1 = "Hello";

        Str1 = "Welcome";

        String Str2 = Str1;


        Console.WriteLine(Str1);
        Console.WriteLine(Str2);
Kamran Khan
  • 1,042
  • 10
  • 21
  • That's not really "making a change to `Str2`", you're just doing the same thing in a different order. The end *behavior* of the strings is still the exact same. – sab669 Aug 17 '15 at 17:36