Closed
Description
Description
ConcurrentStack<T>.PushRange(T[])
throws an ArgumentOutOfRangeException when T[]
is an empty array. The exception message is 'The startIndex argument must be greater than or equal to zero.'.
- This behavior is not documented
- It should do nothing instead of throwing an exception, like
List<T>.AddRange(IEnumerable<T>)
does
Reproduction Steps
new ConcurrentStack<int>().PushRange(Array.Empty<int>());
Expected behavior
It should not throw an exception.
Actual behavior
It throws an ArgumentOutOfRangeException: 'The startIndex argument must be greater than or equal to zero.'
Regression?
No response
Known Workarounds
Check the array for Length > 0
before calling ConcurrentStack<T>.PushRange(T[])
.
Configuration
.NET 6.0.100
Other information
No response