TextBox txtCon = txtCont1; string txtConV = txtCon.Text; //你要分割的值 可在最后+一个分割符 string domo =txtGValue.Text;//分割符 int Strcount = 0; string strconValue = ""; for (int i = 0; i < txtConV.Length; i++) { strconValue = txtConV.Substring(i, 1); if (strconValue == domo) { Strcount++; } } int domoLive = 0; try { for (int i = 1; i <= Strcount + 1; i++) { if (i <= 7) { int num1 = txtConV.IndexOf(domo, domoLive); int sms = num1 - domoLive; if (sms > 0) { string sid = txtConV.Substring(domoLive, sms); //txtCont2.Text = sid; this.Controls["txtCont" + (i + 1).ToString()].Text = sid; //分别显示控件中 domoLive = num1 + domo.Length;//分割符的索引 下次分割以此开始 } } } } catch (Exception ex) { MessageBox.Show(ex.Message); }
string[] _list="123|456|789".Split('|');
110,538
社区成员
642,577
社区内容
加载中
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧