Re: bytes To Hex
- From: "Analizer1" <dvs_bis@xxxxxxxxxxxxx>
- Date: Tue, 5 Feb 2008 11:58:31 -0800
My Byte[] array consists of DirectoryServices Users Sid from the domain
I needed to Convert Each Byte to a Hex String , Then Concatenate each
following byte
below is a example...is the proper way, or is there a better way of
accomplishing this
uint uDec;
for (int x = 0; x < aBytes.GetLength(0); x++)
{
uDec = Convert.ToUInt32(aBytes[x]);
sHexId.Append(String.Format("{0:x2}",uDec));
}
Console.WriteLine(sHexId);
//it matches the hex id Sql Returns
Tks
"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote in message
news:op.t52de5bw8jd0ej@xxxxxxxxxxxxxxxxxxxxxxx
On Tue, 05 Feb 2008 10:04:28 -0800, Analizer1 <dvs_bis@xxxxxxxxxxxxx>
wrote:
Hi I have a Long Number
In a Byte[]
Im not sure how to convert this Byte[] array to a Hex
string
Well, the .NET way would be to use BitConverter to get the bytes into an
actual long value, and then use ToString("x") to convert to hex:
byte[] rgb = { 1, 2, 3, 4, 5, 6, 7, 8 };
string strHex = BitConverter.ToInt64(rgb, 0).ToString("x");
Pete
.
- Follow-Ups:
- Re: bytes To Hex
- From: Jeroen Mostert
- Re: bytes To Hex
- From: Peter Duniho
- Re: bytes To Hex
- From: Jon Skeet [C# MVP]
- Re: bytes To Hex
- References:
- bytes To Hex
- From: Analizer1
- Re: bytes To Hex
- From: Peter Duniho
- bytes To Hex
- Prev by Date: Re: Creating a password login
- Next by Date: Creating COM object written in C#
- Previous by thread: Re: bytes To Hex
- Next by thread: Re: bytes To Hex
- Index(es):
Relevant Pages
|