Skip to content

Commit 9eb0266

Browse files
authored
Unsigned check of index inside ElementAt (#91522)
1 parent 7704164 commit 9eb0266

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/libraries/System.Linq/src/System/Linq/ElementAt.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,11 @@ public static TSource ElementAt<TSource>(this IEnumerable<TSource> source, Index
8787

8888
if (source is IList<TSource> list)
8989
{
90-
return index >= 0 && index < list.Count ? list[index] : default;
90+
return (uint)index < (uint)list.Count ? list[index] : default;
9191
}
9292

9393
TryGetElement(source, index, out TSource? element);
9494
return element;
95-
9695
}
9796

9897
/// <summary>Returns the element at a specified index in a sequence or a default value if the index is out of range.</summary>

0 commit comments

Comments
 (0)