String.insert in C # doesn't overwrite?
6 answers
For example, the return value is "abc" .Insert (2, "XYZ") is "abXYZc".
So no.
http://msdn.microsoft.com/en-us/library/system.string.insert.aspx
+7
source to share
Strings in C # are immutable. They cannot be changed except by reflection or unsafe code (and you should never do that).
All methods on the line that "change" instead return a new line with the appropriate changes.
Since insertion puts one string on top of another, the result of inserting a string s1
into a string s2
will contain the string length s1.Lnegth + s2.Length
, no characters will be lost.
+1
source to share