相关疑难解决方法(0)

有类似 Buffer.LastPositionOf 的东西吗?查找缓冲区中最后一次出现的字符?

我有一个类型的缓冲区ReadOnlySequence<byte>。我想提取的亚序列(其中将包含0 - n条消息)通过知道从它与每一个消息结束0x1c, 0x0d(如所描述的在这里)。

我知道缓冲区有一个扩展方法PositionOf但它

返回第一次出现的位置itemReadOnlySequence<T>

我正在寻找一种方法来返回最后一次出现的位置。我试图自己实现它,这是我迄今为止所拥有的

private SequencePosition? GetLastPosition(ReadOnlySequence<byte> buffer)
{
    // Do not modify the real buffer
    ReadOnlySequence<byte> temporaryBuffer = buffer;
    SequencePosition? lastPosition = null;

    do
    {
        /*
            Find the first occurence of the delimiters in the buffer
            This only takes a byte, what to do with the delimiters? { 0x1c, 0x0d }

        */
        SequencePosition? foundPosition = temporaryBuffer.PositionOf(???);

        // Is there still an occurence?
        if (foundPosition …
Run Code Online (Sandbox Code Playgroud)

c# .net-core

6
推荐指数
0
解决办法
140
查看次数

标签 统计

.net-core ×1

c# ×1