Re: From ushot to byte[]

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

Check out BitConverter.GetBytes(). This just gets the bytes as an array.

"Salvatore Di Fazio" <salvatore.difazio@xxxxxxxxx> wrote in message
news:1126095263.477498.289000@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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


.