diff --git a/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs b/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs index 5d6c9c97573..4898c0cae20 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs @@ -49,7 +49,7 @@ public T this[int index] ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); } - if (index < 0 || index >= items.Count) + if ((uint)index >= (uint)items.Count) { ThrowHelper.ThrowArgumentOutOfRange_IndexException(); } @@ -108,9 +108,9 @@ public void Insert(int index, T item) ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); } - if (index < 0 || index > items.Count) + if ((uint)index > (uint)items.Count) { - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_ListInsert); + ThrowHelper.ThrowArgumentOutOfRange_IndexException(); } InsertItem(index, item); @@ -125,12 +125,12 @@ public void InsertRange(int index, IEnumerable collection) if (collection == null) { - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.list); + ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection); } if ((uint)index > (uint)items.Count) { - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_ListInsert); + ThrowHelper.ThrowArgumentOutOfRange_IndexException(); } InsertItemsRange(index, collection); @@ -198,7 +198,7 @@ public void ReplaceRange(int index, int count, IEnumerable collection) if (collection == null) { - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.list); + ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection); } ReplaceItemsRange(index, count, collection); @@ -211,7 +211,7 @@ public void RemoveAt(int index) ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); } - if (index < 0 || index >= items.Count) + if ((uint)index >= (uint)items.Count) { ThrowHelper.ThrowArgumentOutOfRange_IndexException(); }