temp = \t水小       \t\t\t             \t10只         1鸡        \t速度          \t等会  //temp为在VS里查看temp的值
String[] aa = temp.Split(new char[] {'\t'}); 
取到后的数组为      
水小  
10只         1鸡  //怎么把10只和1鸡给分开呢?                        
速度               
等会    应该实现成下面这样
水小  
10只
1鸡                       
速度               
等会    

解决方案 »

  1.   

    string[] aa = temp.Split(new char[] { '\t',' ' });
      

  2.   

                string[] aa = temp.Split(new char[] { '\t',' ' });
                ArrayList list = new ArrayList();
                for (int i = 0; i < aa.Length; i++)
                {
                    if (aa[i].Length > 0)
                    {
                        list.Add(aa[i]);
                    }
                }
                aa = (string[])list.ToArray(typeof(string));
      

  3.   

    谢谢回复,问题解决了,不过因为是动态取数,共两种情况存在,上面是一种情况,还有另一种
    \tpost time:2011-11-19 22:33:00  \t椰树 \t\t\t \t13只 5鸡 \t速度 \t等会
    如果用你上面写的实现方法
    post
    time:2011-11-19
    22:33:00
    椰树
    13只
    5鸡
    速度
    等会但这个的实现应该是post time:2011-11-19 22:33:00不应该分开
      

  4.   

    为什么要用‘\t’来分割呢temp = \t水小 \t\t\t \t10只 1鸡 \t速度 \t等会temp=temp.Replace('\t','');
    string[] result=temp.Split(' ');