如何拆分字符串并将值分配给文本框

如何拆分字符串并将值分配给文本框

问题描述:

pubilc void test()

{



string str =name = welcome to codeproject; ok = yes;



}

UI图层:]



名称:文本框(分配给str'分割值'name')





结果将显示为

名称:欢迎来到codeproject



我的尝试:



string str =name =欢迎来到codeproject; ok = yes;



string str1 =name = welcome to codeproject;

string str2 =ok =是;

string str = str1 + str2;

pubilc void test()
{

string str = "name=welcome to codeproject;ok=yes";

}
UI layer:]

Name: textbox(to assign the str splitted value of 'name')


result will be displayed like
Name: welcome to codeproject

What I have tried:

string str = "name=welcome to codeproject;ok=yes";

string str1="name=welcome to codeproject";
string str2= "ok=yes";
string str = str1 + str2;

使用如下,

Use like following,
string str = "name=welcome to codeproject;ok=yes";
string[] splitted = str.Split(';');
YourTextBox.Text = splitted[0]; 



了解更多信息,请阅读c#中的字符串。使用以下链接,

1. 字符串方法(系统) [ ^ ]

2. C# - 字符串 [ ^ ]