我现在有一数字字符串
string nums="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16.....1000";
我想每次获取100个数字,第一次是1-100、第二次获取的就是101-200,以此类推.
在这里求一高效能做法。
string nums="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16.....1000";
我想每次获取100个数字,第一次是1-100、第二次获取的就是101-200,以此类推.
在这里求一高效能做法。
解决方案 »
- 各位高手帮忙看看如何用C#向SQL数据库添加数据
- 求助:win7下visual studio2010调试出现以下错误
- 控件上绘制图片问题
- 对于同一网页能申明两个HttpWebRequest 吗?
- c#制作的安装包在别的电脑必须得安装.net framework2.0吗?
- dll共享储存段的问题
- 国内有什么好的B/S开源ERP系统
- 关于C# 刻录程序的问题。 Burning and Erasing CD/DVD/Blu-ray Media with C# and IMAPI2
- arraylist使用出现的问题
- 有关C#中ADODB的RecordsetClass和StreamClass的问题
- SL 入门学习资料
- C#下运算的问题
string[] a=nums.Split(',');
转成数组后你想怎么取就打入下表就可以了!!1-100----就是取下标为a[0]--a[99]
101-200--就是取下标为a[100]--a[199]
.....
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数组,如果你知道肯定是数字,直接从奇数取,不就是最快的了
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());
{
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);
}
热后直接从num里拿
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);
6 楼的似乎比切割要划算的多,切割时间要长啊,但是这么取想要个位数,十位数,百位数……都取对就要麻烦了~还是sqlit划算了~string [] str = nums.sqlit(',');
这样的怎么取呢
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;
}
引用 16 楼 fugees 的回复:
要是string str="1,2.......201"
这样的怎么取呢真不明白你到底在想啥
[/Quote]
你都地想干什么!!