我有一個List<string>
包含N
字符串。從列表中一次處理N個字符串<string>
而且我需要一次處理NN
個字符串,然後在最後一對字符串上執行,這不等於NN
。
例子:
List<string> xList; //Contains 300 string
int N = 100;
int count = //Number of 100s in xList > Couldn't figure it out yet
int counter = 0;
for (int i = 1; i < = count; i++)
{
var vList = xList.Skip(counter).Take(N);
MessageBox.Show(string.Join(Environment.NewLine, vList.ToArray()));
counter += N;
}
現在,如果xList
包含350
?
有沒有更簡單的方法來做到這一點?
你是什麼意思'在xList' 100S數,你能否詳細說明? – Ofiris 2014-10-03 23:40:09
如果'xList'包含300個字符串,那麼'count'將是3 – Enumy 2014-10-03 23:42:23
如果xList包含300,則count爲3.如果xList包含350,那麼count是多少? 3或4? – 2014-10-03 23:47:19