Your question has nothing to do with arrays. Since your data[0] is string - and this is a reference type - this is the value of One , you never change its value. You just created a link to another line t2 and set a point with the same object using the link t1 . After you change this reference object to "Three" , but that will not affect what t1 means.
Look at your code line by line;
var t1 = data[0];
Using this line, you created a link to the line as t1 , and this points to the "One" object.
var t2 = t1;
Using this line, you create a new string link as t2 , and this points to the same object with t1 , which is equal to "One"
t2 = "Three";
Using this line, you create a string object named "Three" , and your t2 refers to this object. It no longer points to the "One" object. But this does not affect the t1 link. It still points to the "One" object.
That's why
Console.WriteLine(t2); Console.WriteLine(t1);
prints
Three One
Soner gönül
source share