我正面临这种异常情况。以下代码无法正常工作:
string temp = "heythere";
Console.WriteLine(temp);
temp.Insert(3, "hello");
Console.WriteLine(temp);
它不是应该输出像“heyhellothere”吗?但它确实“heyrehere”(没有变化)。
最佳答案
字符串是不可变的,它们不会就地改变。尝试:
string temp = "heythere";
Console.WriteLine(temp);
temp = temp.Insert(3, "hello");
Console.WriteLine(temp);
关于c# - textBox1.Text.Insert(...) 方法不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7383975/