你指的是这个超载TryPopRange
吗?
public int TryPopRange(T[] items, int startIndex, int count);
// Exceptions:
// T:System.ArgumentNullException:
// items is a null reference (Nothing in Visual Basic).
//
// T:System.ArgumentOutOfRangeException:
// startIndex or count is negative. Or startIndex is greater than or equal to the
// length of items.
//
// T:System.ArgumentException:
// startIndex + count is greater than the length of items.
这些异常与集合中的项目数量无关ConcurrentStack
,而是与提供的T[] items
参数的大小有关。您应该将一致的值作为参数传递,因此您不能传递items
大小为 10 的数组和大小startIndex
为 11 的数组。