Why string is a reference type?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I dont understand it.

<font size=2><span style="color:rgb(0, 0, 128) System.String hola = "tal";<br style="color:rgb(0, 0, 128) <span style="color:rgb(0, 0, 128) System.String hola2;<br style="color:rgb(0, 0, 128) <br style="color:rgb(0, 0, 128) <span style="color:rgb(0, 0, 128) hola2 = "talycual";<br style="color:rgb(0, 0, 128) <span style="color:rgb(0, 0, 128) Debug.Print(hola2);<br style="color:rgb(0, 0, 128) <span style="color:rgb(0, 0, 128) hola2 = hola;<br style="color:rgb(0, 0, 128) <span style="color:rgb(0, 0, 128) hola = "___";<br style="color:rgb(0, 0, 128) <span style="color:rgb(0, 0, 128) Debug.Print(hola2);</font>


And the output is:

talycual
tal

If string is a reference type ... the output must be at the last line : ____, but hola2 has a copy of hola .

I understand differences between struct and class, and because is struc a value type and because is class a reference type but ... i dont understand because is string a reference type <img src="images/emoticons/smile_sarcastic.gif

Regards.


View the full article
 
Back
Top