Hello
I am not sure about the better way, but your sample is not the best one,
because it's totaly wrong.
More corectly will be:
m_bMsg[0] = (byte)(sTrackNumber & 0xFF); // low byte
m_bMsg[1] = (byte)((sTrackNumber >> 8) & 0xFF); // hi byte
Of course we can swap bytes order. But you need not to shift anything by 16
bits.
--
With best regards,
Andrew
http://www.codeproject.com/script/pr...asp?id=1181072
"Salvatore Di Fazio" <sa***************@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hi guys,
I've a ushort variable and I need to copy it in an array of byte.
I wrote:
m_bMsg[0] = (byte) (p_sTrackNumber & 0xff00 >> 8);
m_bMsg[1] = (byte) (p_sTrackNumber & 0x00ff >> 16);
but I would like to know if exist a better way by a C# class.
Tnx