textBox1.Text.Insert(...) method doesn't work
I'm facing this abnormal situation. The following code doesn't work properly:
string temp = "heythere";
Console.WriteLine(temp);
temp.Insert(3, "hello");
Console.WriteLine(temp);
Isn't it supposed to output like "heyhellothere" ? But 开发者_如何学Cit does "heyrehere" (no change).
Strings are immutable, they don't change in-place. Try:
string temp = "heythere";
Console.WriteLine(temp);
temp = temp.Insert(3, "hello");
Console.WriteLine(temp);
Or, your can try this
string temp = "heythere";
Console.WriteLine(temp.Insert(3, "hello"));
精彩评论