diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Queue.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Queue.cs index 58afecf920c442..2c538149ebdb03 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Queue.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Queue.cs @@ -98,12 +98,12 @@ public void CopyTo(T[] array, int arrayIndex) if (arrayIndex < 0 || arrayIndex > array.Length) { - throw new ArgumentOutOfRangeException(nameof(arrayIndex), arrayIndex, SR.ArgumentOutOfRange_IndexMustBeLessOrEqual); + ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.arrayIndex, ExceptionResource.ArgumentOutOfRange_IndexMustBeLessOrEqual); } if (array.Length - arrayIndex < _size) { - throw new ArgumentException(SR.Argument_InvalidOffLen); + ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); } int numToCopy = _size; @@ -124,23 +124,23 @@ void ICollection.CopyTo(Array array, int index) if (array.Rank != 1) { - throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, nameof(array)); + ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported, ExceptionArgument.array); } if (array.GetLowerBound(0) != 0) { - throw new ArgumentException(SR.Arg_NonZeroLowerBound, nameof(array)); + ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NonZeroLowerBound, ExceptionArgument.array); } int arrayLen = array.Length; if (index < 0 || index > arrayLen) { - throw new ArgumentOutOfRangeException(nameof(index), index, SR.ArgumentOutOfRange_IndexMustBeLessOrEqual); + ThrowHelper.ThrowArgumentOutOfRange_IndexMustBeLessOrEqualException(); } if (arrayLen - index < _size) { - throw new ArgumentException(SR.Argument_InvalidOffLen); + ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); } int numToCopy = _size; @@ -159,7 +159,7 @@ void ICollection.CopyTo(Array array, int index) } catch (ArrayTypeMismatchException) { - throw new ArgumentException(SR.Argument_IncompatibleArrayType, nameof(array)); + ThrowHelper.ThrowArgumentException_Argument_IncompatibleArrayType(); } } @@ -442,7 +442,7 @@ public void Dispose() public bool MoveNext() { - if (_version != _q._version) throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion); + if (_version != _q._version) ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion(); if (_index == -2) return false; @@ -503,7 +503,7 @@ private void ThrowEnumerationNotStartedOrEnded() void IEnumerator.Reset() { - if (_version != _q._version) throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion); + if (_version != _q._version) ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion(); _index = -1; _currentElement = default; }