diff --git a/src/mscorlib/shared/System/ReadOnlySpan.cs b/src/mscorlib/shared/System/ReadOnlySpan.cs index a09314d8fdb7..fdee6012a128 100644 --- a/src/mscorlib/shared/System/ReadOnlySpan.cs +++ b/src/mscorlib/shared/System/ReadOnlySpan.cs @@ -165,15 +165,18 @@ public bool IsEmpty /// /// Thrown when index less than 0 or index greater than or equal to Length /// - public T this[int index] - { #if PROJECTN + public ref readonly T this[int index] + { [BoundsChecking] get { - return Unsafe.Add(ref _pointer.Value, index); + return ref Unsafe.Add(ref _pointer.Value, index); } + } #else + public T this[int index] + { [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] [NonVersionable] @@ -183,8 +186,8 @@ public T this[int index] ThrowHelper.ThrowIndexOutOfRangeException(); return Unsafe.Add(ref _pointer.Value, index); } -#endif } +#endif /// /// Copies the contents of this read-only span into destination span. If the source