数据是用2个tab分开的  ~
用splite怎么切割啊

解决方案 »

  1.   

    那就直接按空格分割呗,分完了再用一个数组存非空格的数据
    如:using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Collections;namespace paidui
    {
        class Program
        {
            static void Main(string[] args)
            {            string str = "1      2      3";
                string[] str1 = str.Split(' ');
                ArrayList str2 = new ArrayList();
                for (int i = 0; i < str.Length; i++)
                {
                    if (str[i]!=' ')
                    {
                        str2.Add(str[i]);
                    }               
                }
                foreach (char item in str2)
                {
                    Console.WriteLine(item);
                }
                Console.ReadLine();
            }
        }
    }
      

  2.   

    但数据不是用空格分开的啊~不然用空格我也知道   每个数据之间是2个tab分开的
      

  3.   

    Tab其实就是多个空格组成的,一般3个空格。
      

  4.   

    字符串.Split(new string[] { "\t\t" }, StringSplitOptions.RemoveEmptyEntries);
    或者
    System.Text.RegularExpressions.Regex.Split(字符串, @"\t\t");
      

  5.   

    原先代码有错,更改下……4楼的那个方法好像没分割成功,是不是还少什么            //以两个Tab分割字符串
                string str = "asdase      bbsdsd      casddc";
                string[] str1 = str.Split(' ');
                ArrayList str2 = new ArrayList();
                for (int i = 0; i < str1.Length; i++)
                {
                    if (str1[i] !="")
                    {
                        str2.Add(str1[i]);
                    }
                }
                foreach (string item in str2)
                {
                    Console.WriteLine(item);
                }
                Console.ReadLine();
      

  6.   


    那是因为Visual Studio中在字符串里面直接敲tab键默认会转成空格:string tab1 = "\t";
    string tab2 = " ";    // 直接敲tab键
    string tab3 = @"    ";    // 先敲@再敲tab
    byte[] byte1 = Encoding.UTF8.GetBytes(tab1);    // 0x09
    byte[] byte2 = Encoding.UTF8.GetBytes(tab2);    // 0x20
    byte[] byte3 = Encoding.UTF8.GetBytes(tab3);    // 0x20,0x20,0x20,0x20