When getting substring in .Net, does the new string reference the same original string data or does
- by Elan
Assuming I have the following strings:
string str1 = "Hello World!";
string str2 = str1.SubString(6, 5); // "World"
I am hoping that in the above example str2 does not copy "World", but simply ends up being a new string that points to the same memory space only that it starts with an offset of 6 and a length of 5.
In actuality I am dealing with some potentially very long strings and am interested in how this works behind the scenes for performance reasons. I am not familiar enaugh with IL to look into this.