TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jay S
NA
230
59.7k
[C#} Loop byte by byte comparing short value
Mar 13 2014 12:51 PM
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.
Reply
Answers (
3
)
please i need help ... i'm stuck with my project
How to change font of controls as screen size get change.