Groups | Blog | Home
all groups > vb.net > february 2005 >

vb.net : Convert UInt16 to Byte Array



Herfried K. Wagner [MVP]
2/3/2005 4:55:11 PM
"rawCoder" <rawCoder@hotmail.com> schrieb:
[quoted text, click to view]

'BitConverter.GetBytes' provides an overload for 'UInt16'/'UInt32', but on
Windows it will work in Little Endian format only. Jon Skeet [MVP] provides
a class named 'EndianBitConverter' that can be used with Big and Little
Endian format:

Miscellaneous Utility Library
<URL:http://www.yoda.arachsys.com/csharp/miscutil/>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
rawCoder
2/3/2005 8:48:07 PM
Hi,

Ok this shud b simple but i cant seem to find it.

I want to convert a System.UInt16 data to 2 Byte array and System.UInt32
data to 4 Byte array ( BigEndian)

something like
Public Sub GetBytes(ByVal n as System.UInt16, ByRef b As Byte())
'Converts the System.UInt16 to a 2 Byte array
void GetBytes( n System.UInt16, Byte b[] )
// Converts the System.UInt16 to a 2 Byte array
* ( UnCompiled)

Sorry if i am asking for a spoon feed :-)

Thanx,
rawCoder

AddThis Social Bookmark Button