我现在有一数字字符串
string nums="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16.....1000";
我想每次获取100个数字,第一次是1-100、第二次获取的就是101-200,以此类推.
在这里求一高效能做法。

解决方案 »

  1.   

    string nums="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16.....1000"; 
    string[] a=nums.Split(',');
    转成数组后你想怎么取就打入下表就可以了!!1-100----就是取下标为a[0]--a[99]
    101-200--就是取下标为a[100]--a[199]
    .....
      

  2.   


    string nums="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16.....1000"; 
    for(int i=0;i<maxCount;i+=2)
    {
        int numValue = int.Parse(nums[i].ToString());
    }
    string本身就是char数组,如果你知道肯定是数字,直接从奇数取,不就是最快的了
      

  3.   

    string str = "2,2,5,8,5,4,8,4,6,6,8,5,5,5,68,1,8,5,55,6,5,4,8,5";
                string[] arr = str.Split(',');
                var a = from b in arr
                        where int.Parse(b) > 5
                        select b;
                foreach (string m in a)
                    Console.WriteLine(m.ToString());
      

  4.   

    for (int i = 0; i < 10; i++)
                {
                    string hex = string.Empty;
                    for (int j = i * 100; j < (i + 1) * 100; j++)
                    {
                         hex += hexValuesSplit[j];
                    }
                    //hex += "\r\n";
                    //this.listBox1.Items.Add(hex);
                    //this.listView1.Items.Add(hex);
                }
      

  5.   

    首先string [] num=nums.sqlit(',');
    热后直接从num里拿
      

  6.   

    类型转换只进行依次 想怎么读取就怎么读取,无非就是内存Copy了            string str = "2,2,5,8,5,4,8,4,6,6,8,5,5,5,68,1,8,5,55,6,5,4,8,5";
                string[] arr = str.Split(',');
                IntPtr block=Marshal.AllocHGlobal(arr.Length * 4);
                for(int i=0;i<arr.Length;i++)
                {
                    Marshal.WriteInt32(block,i*4,Int32.Parse(arr[i]));
                }
                int c=10;
                int[] huhu = new int[100];
                //读取  可以直接拷贝内存块也可以一个一个读取
                Marshal.Copy(new IntPtr(block.ToInt64() + (c * 4)), huhu, 0, 100);
      

  7.   


    6 楼的似乎比切割要划算的多,切割时间要长啊,但是这么取想要个位数,十位数,百位数……都取对就要麻烦了~还是sqlit划算了~string [] str = nums.sqlit(',');
      

  8.   

    要是string str="1,2.......201"
    这样的怎么取呢
      

  9.   


        string[] strNum = "1,2,3,4,5,6,7,8,9,10...1000".Split(',');
                //用于存储10个分组数据用的
                List<string>[] lstNumArray = new List<string>[10];            
                int count = 0;
                for (int j = 0; j < 1000;)
                {
                    lstNumArray[count] = new List<string>();
                    for (int i = j; i < j+100; i++)
                    {                    
                        lstNumArray[count].Add(strNum[i]);
                    }
                    j += 100;
                    count += 1;
                }
      

  10.   


    引用 16 楼 fugees 的回复:
    要是string str="1,2.......201"
    这样的怎么取呢真不明白你到底在想啥
    [/Quote]
    你都地想干什么!!