I am trying to loop through some bytes using the binaryreader class, I want to compare a short value to each short value, but rather than moving 2 bytes within the stream, move 1 byte and re-compare the short value.
As it stands I can currently compare byte for byte:
byte b0 = (byte)num9; //get single byte value from volume. num9 = short
//loop through remaining bytes until we find value *should* be the only occurance eek.
do
{
binaryReader.ReadByte();
}
while (binaryReader.ReadByte() != b0);
While this kinda works it doesn't always return what I expect. If I use binaryReader.ReadInt16() then I will miss possible matches.
Ideally I dont want to read the bytes into the array,find the index and move the base stream position...I really want to check each possible short value in the remaining bytes...
The way I see it is something like this (on the basis that a short is 2 bytes):
byte1
byte2
byte3
byte4
byte5
[byte1, byte2]...[byte2, byte3]...[byte3, byte4]...[byte4, byte5]
Any help would be great..I just can't seem to visualise what to do.