在委托字符串中替换方法 [英] replace method in delegate string

查看:141
本文介绍了在委托字符串中替换方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题,我收到一些数据,并显示在文本框中调用它我使用

i have got a little problem i received some data and show it in textbox to invoke it i used

if (textBox1.InvokeRequired)
{
    // this is worker thread
    updatetextBoxDelegate del = new updatetextBoxDelegate(updatetextBox);
    textBox1.Invoke(del, new object[] { data });
}

我的数据就像
名称:sam
年龄:10

my data is like name:sam age:10

现在我想分割它,并将这些值保存在数组中或显示在sperate文本框中
i使用替换方法,如

now i want to split it and save these values in array or show in sperate textboxes i used replace method like

string str = textBox1.text;
str.Replace("name","");

等等,但问题是替换方法不工作它剂量不替代任何东西
告诉我我在做错什么

and so on but the problem is replace method is not working on it it doses not replace any thing tell me what i am doing wrong

推荐答案

如果你看这里: http://msdn.microsoft.com/en-us/library/fk49wtc1.aspx ,你会看到替换方法返回一个字符串,你必须捕获它,所以替换:

If you look here: http://msdn.microsoft.com/en-us/library/fk49wtc1.aspx, you'll see the Replace method returns a string you have to "catch" it, so replace:

str.replace("name","");

str = str.Replace("name", "");

这篇关于在委托字符串中替换方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆