求助??? 急 对字符串的截取 最短租期:半年|付款要求:年付|押金要求:两月租金|入住时间:agew|看房时间:gaweg 截取:跟|之间的字符 c#并将值赋给指定的文本框中 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 提供个思路:用string的split方法,可以先split‘|’,然后split‘:’;也可以直接split‘|’和‘:’,然后取奇数下标的值。 string str = "最短租期:半年|付款要求:年付|押金要求:两月租金|入住时间:agew|看房时间:gaweg";string[] array = str.Split('|');txt.Text=array[0].toString();txt.Text=array[1].toString();txt.Text=array[2].toString();txt.Text=array[3].toString();txt.Text=array[4].toString(); string _ValueText = "半年|付款要求:年付|押金要求:两月租金|入住时间:agew|看房时间:gaweg "; string[] _Value = _ValueText.Split(new char[]{':'},StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i != _Value.Length; i++) { string[] _Text = _Value[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (_Text.Length == 2) { MessageBox.Show(_Text[0], _Text[1]); } } string str = "最短租期:半年|付款要求:年付|押金要求:两月租金|入住时间:agew|看房时间:gaweg";string[] array = str.Split('|');txt.Text=array[0].toString();txt.Text=array[1].toString();txt.Text=array[2].toString();txt.Text=array[3].toString();txt.Text=array[4].toString(); string[] strs = "你的字符串".split('|'); 测试过的代码:string _ValueText = "工期:半年|付款要求:年付|押金要求:两月租金|入住时间:agew|看房时间:gaweg ";char[] sep ={ '|',':' };string[] val = _ValueText.Split(sep);for (int i = 0; i < val.Length; i++){ if (i % 2 == 1) MessageBox.Show(val[i]);} string[] array = str.Split(new char[2]{':','|'}); for (int i = 0; i < array.Length; i++) { switch (array[i].ToString()) { case "最短租期": for (int j = 0; j <rblShortLease.Items.Count; j++) { if (rblShortLease.Items[j].Text == array[i + 1].ToString()) rblShortLease.Items[j].Selected = true; }; break; case "付款要求": for (int j = 0; j < rblPay.Items.Count; j++) { if (rblPay.Items[j].Text == array[i + 1].ToString()) rblPay.Items[j].Selected = true; }; break; case "押金要求": for (int j = 0; j < rblForegift.Items.Count; j++) { if (rblForegift.Items[j].Text == array[i + 1].ToString()) rblForegift.Items[j].Selected = true; }; break; case "入住时间": txtLiveDate.Text = array[i + 1].ToString(); break; case "看房时间": txtLookDate.Text = array[i + 1].ToString(); break; } } c# 如何把查询后的数据,调到“label”控件的中 然后显示出数据! 验证textbox中只能输入中文 如何在实现接口时,自动用Region把实现的方法包含 程序中批量转换wav到mp3的问题 C#的全局变量 求助,一个程序按照运行不出来 如何处理tableAdapterManager中的事务?急 一个非常好的盗版电子书籍下载网站。非常全面! 问一个问题,关于继承的。 高分求救。。 郁闷的Socket问题,是我没搞懂http头文件吗?请教 【求两个正则】
string[] array = str.Split('|');
txt.Text=array[0].toString();
txt.Text=array[1].toString();
txt.Text=array[2].toString();
txt.Text=array[3].toString();
txt.Text=array[4].toString();
{
string[] _Text = _Value[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
if (_Text.Length == 2)
{
MessageBox.Show(_Text[0], _Text[1]);
}
}
string[] array = str.Split('|');
txt.Text=array[0].toString();
txt.Text=array[1].toString();
txt.Text=array[2].toString();
txt.Text=array[3].toString();
txt.Text=array[4].toString();
char[] sep ={ '|',':' };
string[] val = _ValueText.Split(sep);
for (int i = 0; i < val.Length; i++)
{
if (i % 2 == 1) MessageBox.Show(val[i]);
}
for (int i = 0; i < array.Length; i++)
{
switch (array[i].ToString())
{
case "最短租期":
for (int j = 0; j <rblShortLease.Items.Count; j++)
{
if (rblShortLease.Items[j].Text == array[i + 1].ToString())
rblShortLease.Items[j].Selected = true;
}; break;
case "付款要求":
for (int j = 0; j < rblPay.Items.Count; j++)
{
if (rblPay.Items[j].Text == array[i + 1].ToString())
rblPay.Items[j].Selected = true;
}; break;
case "押金要求":
for (int j = 0; j < rblForegift.Items.Count; j++)
{
if (rblForegift.Items[j].Text == array[i + 1].ToString())
rblForegift.Items[j].Selected = true;
}; break;
case "入住时间": txtLiveDate.Text = array[i + 1].ToString(); break;
case "看房时间": txtLookDate.Text = array[i + 1].ToString(); break;
}
}