user3363022 user3363022 - 1 year ago 62
C# Question

When i iterate through count, my array changes size, why?

When I run a simple code designed to make a training and testing data cross-validate, I iterate through each count of my list but each time it iterates the list decreases by 1.

for (var i = 0; i < adjustedData.Count; i++)
var tempData = adjustedData;
var testData = tempData[i].ToArray();
var trainDataList = tempData;
var trainData = trainDataList.ToArray();

Answer Source

Shouldn't that be cause your code is removing the item from array/list. The below code line

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download