有字符串 " a|b|||d|"   或 "|b|||e|"  
应该怎么取"|"中间的字符a,b等等,并判断这个字符在在那个位置啊?

解决方案 »

  1.   


    string str = "a|b|||d|";
    str = str.Split('|');
      

  2.   

    用STRING 的SPLIT方法.如: 
    string my_string =" a ¦b ¦ ¦ ¦d ¦" ;string[] my_split = new string[];my_split = my_string.split('¦'); 
    这样就把数据以¦为边界将其拆开,位置就是该数组的角标.
      

  3.   

                string[] larry_temp;
                string lstg_temp = "a ¦b ¦ ¦ ¦d ¦";            lstg_temp.Replace("¦ ¦ ¦", "¦");
                larry_temp=lstg_temp.Split('¦');            for (int lint_index = 0; lint_index < larry_temp.Length; lint_index++)
                {
                    if (larry_temp[lint_index] != " " & larry_temp[lint_index] != "")
                    {
                    MessageBox.Show(larry_temp[lint_index]);
                    }
                }