문제

내가 쓸 때 :

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