How to convert a byte() to string

  • Thread starter Thread starter Dean Slindee
  • Start date Start date
D

Dean Slindee

I have a timestamp field that I would like to display in a textbox. The
timestamp is an 8 byte array. Can this be converted to a string in one
statement or does it require cycling thru one byte at a time.

Thanks,
Dean Slindee
 
Dean,
If this is SQL Server's TimeStamp, I would not recommend
System.Text.Encoding as the Encoding class assumes you have valid characters
in it. I understand SQL Server's TimeStamp is closer to an Int64.

I would probably use BitConverter.ToString:

Dim bytes() As Byte = {1, 2, 3, 4, 5, 6, 7, 8}
Dim s As String = BitConverter.ToString(bytes)

Which unfortunately puts hyphens between the bytes. If you don't want the
hyphens, then I would use a Loop to convert each byte...

--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley - http://www.tsbradley.net


|I have a timestamp field that I would like to display in a textbox. The
| timestamp is an 8 byte array. Can this be converted to a string in one
| statement or does it require cycling thru one byte at a time.
|
| Thanks,
| Dean Slindee
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top