Skip to content

Commit

Permalink
Unsigned check of index inside ElementAt (#91522)
Browse files Browse the repository at this point in the history
  • Loading branch information
YohDeadfall authored Sep 4, 2023
1 parent 7704164 commit 9eb0266
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/libraries/System.Linq/src/System/Linq/ElementAt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ public static TSource ElementAt<TSource>(this IEnumerable<TSource> source, Index

if (source is IList<TSource> list)
{
return index >= 0 && index < list.Count ? list[index] : default;
return (uint)index < (uint)list.Count ? list[index] : default;
}

TryGetElement(source, index, out TSource? element);
return element;

}

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

0 comments on commit 9eb0266

Please sign in to comment.