TRW,
BitConverter can go both ways.
For example BitConverter.ToUInt16 will take the array & convert it to an
unsigned short.
While BitConverter.GetBytes(System.UInt16) will take an unsigned short &
convert it to a byte array.
Hence I would use BitConverter.GetBytes to convert the unsigned short to a
byte array, then use Array.Copy or Buffer.BlockCopy to "put" this byte array
into the larger byte array.
I normally prefer BinaryWriter (possibly over a MemoryStream) as it
encapsulates the above nicely.
Hope this helps
Jay
"TRW" <TR*@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.com...
Thanks Jay for the help. I will look those over.
I thought the BitConverter would get the data out of the byte array for me
but
not put it. I will recheck.
thanks again!
"Jay B. Harlow [MVP - Outlook]" wrote:
TRW1313,
I would consider using either a System.IO.BinaryWriter or the methods on
System.BitConverter along with Array.Copy or Buffer.BlockCopy.
Hope this helps
Jay
"TRW1313" <TR*****@discussions.microsoft.com> wrote in message
news:E8**********************************@microsof t.com... > I'm looking to populate a byte array of some fixed size to send out
> over
> a UDP connection. The data in the byte array is mixed between
> characters
> and binary.
>
> I'm a beginner to this language.
>
> I can assign the character data by the byte. However, I'm not sure
> how I
> would
> assign a binary value to a certain location in a byte array where the
> value is
> greater than 255. I have an unsigned short and want to assign it to a
> specific
> location in the byte array.
>
> What is the best way to do this?
>
> thanks!