Storing a word inside a Byte array

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



Hi all,

I have the following:

byte[] msgData = new byte[100];
ushort aaa = 0xFFFA;



Now I would like to store that variable aaa in the array
so at the end I would have something like:
msgData[0] = 0xFF;
msgData[1] = 0xFA;

Since I cannot do something like this:
m_buffer[0] = aaa;

Is there an easy and fast way of doing that?
I know i can extract the first byte from aaa and put it in msgData[0]
and the same with the second byte, but I was wondering if there is something simpler than that.

I'm afraid this is a trivial question, but I haven't been able
to find the answer.

Thanks!
.



Relevant Pages

  • Re: Storing large number of values in 2D array
    ... declare a 2D array of points. ... Store points in the array. ... Retireve them ...
    (comp.lang.c)
  • Re: Storing a word inside a Byte array
    ... ushort aaa = 0xFFFA; ... Now I would like to store that variable aaa in the array ... Array.Copy, aSize, 2): ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Storing a word inside a Byte array
    ... ushort aaa = 0xFFFA; ... Now I would like to store that variable aaa in the array ... I'm afraid this is a trivial question, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Finding the nearest match without reusing results
    ... comparing an array with a value generates an array of Trues and ... Any diff with wrong State or with used Store is implicitly zeroed out. ... Each must be larger than the absolute value of the maximum Sales ... go.....it just needs to return the closest match. ...
    (microsoft.public.excel.programming)
  • Re: read keyboard input and storing in an array?
    ... > I'm trying to store user input in an array, ... You have the beginnings of that logic already since your prompt tells the ... 201st value since the array only has room for 200 values. ... This will force you to store the int values as Integer ('Integer' ...
    (comp.lang.java.help)