Closed
Description
Description
This code:
ReadOnlySequence<byte> bufferA = new ReadOnlySequence<byte>( new byte[50] );
ReadOnlySequence<byte> bufferB = new ReadOnlySequence<byte>( new byte[45] );
ReadOnlySequence<byte> slice = bufferA.Slice( bufferB.End );
long test = slice.Length;
Throws on the last line:
System.InvalidCastException: 'Unable to cast object of type 'System.Byte[]' to type 'System.Buffers.ReadOnlySequenceSegment`1[System.Byte]'.'
As discussed in #766, this behavior is expected, but:
- The exception could be more helpful here.
- The docs don't mention the late throwing behavior: https://docs.microsoft.com/en-us/dotnet/api/system.buffers.readonlysequence-1?view=net-5.0
Discussed this with @tannergooding on discord.