找出库存清理里的 bug

来自 集合
C# 14 / .NET 10 入门 4分钟 找出 1处问题

找出这段库存清理代码中的集合错误。

csharp
using System.Collections.Generic;

var stock = new List<int> { 4, 0, 7, 0 };

foreach (int quantity in stock)
{
    if (quantity == 0)
    {
        stock.Remove(quantity);
    }
}
在试验场中打开
报告错误