日期:2014-05-18 浏览次数:21169 次
string str = "";
string[] myAsk = null;
myAsk = textbox2.Split(new char[] { ';' });
for (int i = 0; i < myAsk .Length; i++)
{
    这里做SQL语句了。
}
------解决方案--------------------
using System;
using System.Text.RegularExpressions;
class Test
{
  static void Main()
  {
    string s1 = "A、安全阀           B、爆破片           C、压力表           D、温度计";
    Match m = Regex.Match(s1, @"A、(?<a>.*?)\s*B、(?<b>.*?)\s*C、(?<c>.*?)\s*D、(?<d>.*)");
    if (m.Success)
    {
      Console.WriteLine("A: [{0}]", m.Groups["a"].Value);
      Console.WriteLine("B: [{0}]", m.Groups["b"].Value);
      Console.WriteLine("C: [{0}]", m.Groups["c"].Value);
      Console.WriteLine("D: [{0}]", m.Groups["d"].Value);
    }
  }
}
------解决方案--------------------
考虑到答案中可能会出现空格,字母等等。所以用字符串自带的分离函数可能不太合适。
用正则表达式吧.
另外,在textBox2中你可以将输入用回车分开,那用分离函数就好了。