我(希望)有一个简单的问题。
String.Insert(0, "test");
无效,但是:
String.Text += "test";
确实..?我需要插入,所以我可以在字符串的中间插入一些东西。
答案 0 :(得分:6)
我是个白痴,谷歌即时搜索解决了这个问题。
String.Insert不会修改调用它的字符串,而是返回一个带有插入文本的新字符串。
所以我需要:
String = String.Insert(0, "test");
答案 1 :(得分:2)
它应该有用
见下面的例子
string names = "Romeo Juliet";
string shakespeare = names.Insert(6, "and ");
Console.WriteLine(shakespeare);
结果将是罗密欧与朱丽叶