当我写信时:

var tagType = _reader.ReadByte();

while (tagType != 8)
{
    var skip = ReadNext3Bytes() + 11;
    _reader.BaseStream.Position += skip;

    tagType = _reader.ReadByte();
}

...它在工作,但是当我写作时:

var tagType = _reader.ReadByte();

while (tagType != 8)
{
    _reader.BaseStream.Position += ReadNext3Bytes() + 11; 
     tagType = _reader.ReadByte();
}

...它不起作用,我不明白为什么 - 我会得到意外的结果。这是 ReadNext3Bytes 方法:

    private long ReadNext3Bytes()
    {
        try
        {
            return Math.Abs((_reader.ReadByte() & 0xFF) * 256 * 256 + (_reader.ReadByte() & 0xFF) 
                * 256 + (_reader.ReadByte() & 0xFF));
        }
        catch 
        {
            return 0;
        }
    }

为什么这样做,我该如何修复?

谢谢。

有帮助吗?

解决方案

从那以后发生 位置 在期间更改 Readbyte 致电,您看到的与这种情况相似:

int position = 1;
position += (position = 2) + 3;

Assert.AreEqual(6, position);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top