From MS Docs page on Span<T>.Slice(int) method: ArgumentOutOfRangeException is thrown if index(probably start?) is less than zero or greater than or equal to Length.
However, span.Slice(span.Length) does not seem to throw; The example code below executes with no problem.
"asd".ToCharArray().AsSpan().Slice(3)
It appears to be an incorrect document rather than a problem with the implementation, as the documentation for ReadOnlySpan<T>.Slice(int) says that ArgumentOutOfRangeException is thrown if start is greater than the number of items in the read-only span.
Is this behaviour expected? I also have found that XML documentations on these methods (Span.Slice, ReadOnlySpan.Slice) says so as well.
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown when the specified <paramref name="start"/> or end index is not in range (<0 or >=Length).
/// </exception>
<0 or >=Length seems to imply that it should throw if I pass Length as the parameter.
From MS Docs page on Span<T>.Slice(int) method:
ArgumentOutOfRangeExceptionis thrown ifindex(probablystart?) is less than zero or greater than or equal to Length.However, span.Slice(span.Length) does not seem to throw; The example code below executes with no problem.
It appears to be an incorrect document rather than a problem with the implementation, as the documentation for ReadOnlySpan<T>.Slice(int) says that
ArgumentOutOfRangeExceptionis thrown ifstartis greater than the number of items in the read-only span.Is this behaviour expected? I also have found that XML documentations on these methods (Span.Slice, ReadOnlySpan.Slice) says so as well.
<0 or >=Lengthseems to imply that it should throw if I pass Length as the parameter.