C# 我需要:“;当textBox1.Length=4/1索引元素时,添加&引用;通过插入“;
我的代码:C# 我需要:“;当textBox1.Length=4/1索引元素时,添加&引用;通过插入“;,c#,C#,我的代码: int len = textBox1.Text.Length; if (len == 4) { int one = 1; string empty = " "; textBox1.Text.Insert(one, empty); } 字符串是不可变的,您不能修改它们,只需创建一个新的字符串即可。因此,您需要将Insert的结果分配回Text属性: textBox1.Text = textBox1.Text.Insert(one, empty); 你想在这里完成
int len = textBox1.Text.Length;
if (len == 4)
{
int one = 1;
string empty = " ";
textBox1.Text.Insert(one, empty);
}
字符串是不可变的,您不能修改它们,只需创建一个新的字符串即可。因此,您需要将
Insert
的结果分配回Text
属性:
textBox1.Text = textBox1.Text.Insert(one, empty);
你想在这里完成什么?