如何从数组中拆分或复制值? [英] how to split or copy the value from array?
本文介绍了如何从数组中拆分或复制值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友们,
如果你解决了以下问题,你将非常感谢。
i在阵列中有1000个文件。我想要处理前500个文件。接下来要处理的下一个500个文件。
现在我的问题是,有没有可能基于分割数组索引?
或者我们可以将剩下的500复制到下一个阵列吗?
谢谢和问候
Jai
解决方案
嗨jai,
试试这个
// temp class ading to list(你可以创建List< string>像这样;
List< TestClass> ListDevLog = new List< TestClass>();
// 这是数组类型,如string []
TestClass [] objDevLogArr y;
// 如果计数超过500
< span class =code-keyword> if (ListDevLog.Count > 500 )
{
// 然后划分为500(所以这里分为2部分)
double temp = Math.Floor(Convert.ToDouble(ListDevLog.Count / 500 ));
// 这是基于临时计数的循环
for ( int i = 0 ; i < temp; i ++)
{
// 完成500个文件后,你可以在这里处理500个文件
// 从列表中删除这些文件
ListDevLog.RemoveRange( 0 , 500 );
}
}
您可以将<#href =http:/中的c#代码转换为vb代码/www.developerfusion.com\">www.developerfusion.com 网站
Dear Friends,
You will be very much thankful if you solve the below problem.
i have 1000 files in an array.i want to process the first 500 files.after that next 500 files i want to process.
Now my problem was, is there any possibility to split the array based on index?
or else can we copy the remaining 500 to next array?
Thanks & Regards
Jai
解决方案
Hi jai,
try this
//temp class ading to list ( you can create List<string> like this; List<TestClass> ListDevLog = new List<TestClass>(); //this is array type like string[] TestClass[] objDevLogArry; //if count more than 500 if (ListDevLog.Count > 500) { //then devided by 500 ( so here spilt in to 2 parts) double temp = Math.Floor(Convert.ToDouble(ListDevLog.Count / 500)); //this is loop based on temp count for (int i = 0; i < temp; i++) { //here you can process you 500 files //after completing your 500 files process.. just remove those files from list ListDevLog.RemoveRange(0, 500); } }
you can convert c# code to vb code in www.developerfusion.comsite
这篇关于如何从数组中拆分或复制值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文