C# 替换委托字符串中的方法
我有一个小问题,我收到了一些数据,并显示在文本框中,以调用我使用的数据C# 替换委托字符串中的方法,c#,delegates,replace,C#,Delegates,Replace,我有一个小问题,我收到了一些数据,并显示在文本框中,以调用我使用的数据 if (textBox1.InvokeRequired) { // this is worker thread updatetextBoxDelegate del = new updatetextBoxDelegate(updatetextBox); textBox1.Invoke(del, new object[] { data }); } 我的数据就像 姓名:山姆 年龄:10 现在我想拆分它,并
if (textBox1.InvokeRequired)
{
// this is worker thread
updatetextBoxDelegate del = new updatetextBoxDelegate(updatetextBox);
textBox1.Invoke(del, new object[] { data });
}
我的数据就像
姓名:山姆
年龄:10
现在我想拆分它,并将这些值保存在数组中或显示在sperate文本框中
我用了类似的替换方法
string str = textBox1.text;
str.Replace("name","");
等等,但问题是替换方法不起作用,它不能替换任何东西
告诉我我做错了什么如果你看这里:,你会看到Replace
方法返回一个字符串,你必须“捕获”它,所以Replace:
str.replace("name","");
与
str = str.Replace("name", "");