我的两个 ForEach 循环允许访问errorOrders
(用户名及其错误数)和totalOrders
(用户名及其总订单数)。
我的代码不断循环通过这两个 ForEache。两者的“计数”都是 38 errorOrders
,totalOrders
程序循环遍历所有 38 个用户就好了。但随后它会一次又一次地循环遍历它们,重新执行刚刚完成的过程。
我怎样才能遍历用户一次?
foreach (KeyValuePair<string, int> error in errorOrders)
{
foreach (KeyValuePair<string, int> total in totalOrders)
{
errPercentage = ((double)error.Value / (double)total.Value);
Console.WriteLine("Percentage of errors for " + total.Key + ": " + Math.Round(errPercentage, 2) * 100 + "%");
ordersPerHour = OrdersPerHour(total.Key);
RandomOrders = RandomSelect(errPercentage, total.Key);
Console.WriteLine("Number of orders pulled : " + RandomOrders.Rows.Count);
//Print out orders randomly collected
for (int i = 0; i < RandomOrders.Rows.Count; i++)
{
Console.WriteLine(RandomOrders.Rows[i]["ControlNumber"]);
}
Console.WriteLine("\r\n");
//NumOrdersToPull = FindNumOrdersToPull(Math.Round(errPercentage,2), ordersPerHour);
}
}