Send int from C# over Serial

Robin2:
If you send an integer from C# (or any other PC program) it will be received by the Arduino as 2 bytes - let's call them b0 and b1. You can convert them to an integer simply by multiplying b0 x 256 and adding b1.

BUT ... you have to know whether C# sends the high byte or the low first. The maths in my first para assume the high byte is sent first (I don't know C#).

@Robin2 : int in C# is 4 bytes. So, I think you meant that - if I send int from C#, it will be received in Arduino as 4 bytes. In the above post of mine which has different methods to send the data, one of them is BitConverter class which helps to get bytes for corresponding data(type).

Probably somebody could give more clarity on this, but Serial transfer is done by agreement on endian-ness of data and I think in this case lowest significant byte/data goes first and then higher significance and so on. If this is correct, then I can use the shift operation to shift the incoming higher significance byte by 256/512 etc. and then add the lower significance byte to get my integer. Not sure if this is correct, but will be helpful to hear from somebody.