Skip to content

Instantly share code, notes, and snippets.

@davidfowl
Created January 26, 2020 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidfowl/ac86c9b8305026fca067641f7502060c to your computer and use it in GitHub Desktop.
Save davidfowl/ac86c9b8305026fca067641f7502060c to your computer and use it in GitHub Desktop.
Found while bedrocking
using System;
using System.Buffers;
namespace ConsoleApp91
{
class Program
{
static void Main(string[] args)
{
var segment = new Segment(new byte[] { 1, 2, 3 });
var segment2 = new Segment(new byte[] { 4, 5, 6 });
segment.NextSegment = segment2;
var reader = new SequenceReader<byte>(new ReadOnlySequence<byte>(segment, 0, segment, 1));
reader.IsNext(new byte[] { 1, 2 });
}
}
public class Segment : ReadOnlySequenceSegment<byte>
{
public Segment(byte[] data) => Memory = data;
public Segment NextSegment { get => (Segment)Next; set => Next = value; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment