I am receiving an array of bytes periodically, of irregular size. What i am looking for is a specific size, since each received message has a consistent size of 27 bytes. It looks something like this:
"0 2 0 ....... XX 0"
so sometimes the received array will look like this "0 0 2 .... "
I can use the BinarySearch function in http://msdn.microsoft.com/en-us/library/aa310858(v=vs.71).aspx
to help me identify the index of the first zero i find, then check if the next byte is 2. However, if that's not the case, i move on to the next index, and continue checking and so on. But it seems to me like this isn't a good way, and is going to lead to some messy code. Does anybody have a better idea to help me identify the start of a read byte?
BinarySearchwill not work for you. That said, I don't understand what your task is. Are you just searching a byte array for0followed by2?