How to convert a Byte into an Int in C# [closed]

It would be helpful to know what “failed” means: did it not compile? Did it throw and exception? If so, what was the full message of the exception?

In any case, BitConverter.ToInt32 looks at exactly 4 bytes and will throw an exception if your array has less than 4 bytes.

If you want to convert a single byte to an int, just assign it. It will be implicitly casted.

byte myByte = 0;
int myInt = myByte;

Leave a Comment