I have a byte Array that contains the char '%' (25 hex, 37 decimal). I would like to get the index of this byte, however, none of these methods work, and -1 is returned. How to get the index of a specific byte in a byte array?
int byteIndex = Array.IndexOf(bytesDataArray, '%');
int byteIndex = Array.IndexOf(bytesDataArray, 37);
int byteIndex = Array.IndexOf(bytesDataArray, 0x25);
Array.IndexOfhas overloads which takeobject, and so you need to make sure that the data type of the thing you're searching for is correct. You've got an array of bytes, but you're passing a char, and then two ints. If you make sure that you always pass a byte, everything works