h
how can I convert a byte array to string, so that the bytes appear in hex format in the string. Can anyone help
John 10 1333
Hi John,
Normaly Jon answers this, I did not see him some days, I try it.
A string is in unicode format, 2Bytes in dotNet programs.
Maybe you do you want to convert an byte array which holds extended ASCII to
a string?
(Which than will be unicode 2Bytes).
In VB there there are two functions for that Chr and ChrW while the last is
advised.
Cor
Hi John,
Normaly Jon answers this, I did not see him some days, I try it.
A string is in unicode format, 2Bytes in dotNet programs.
Maybe you do you want to convert an byte array which holds extended ASCII to
a string?
(Which than will be unicode 2Bytes).
In VB there there are two functions for that Chr and ChrW while the last is
advised.
Cor
byte[] bs = {0xef, 0xee, 0xaa}
foreach (byte b in bs
System.Console.WriteLine(b.ToString("x"))
Tu-Thac www.ongtech.co
----- John Sturm wrote: ----
h
how can I convert a byte array to string, so that the bytes appear in hex format in the string. Can anyone help
John
byte[] bs = {0xef, 0xee, 0xaa}
foreach (byte b in bs
System.Console.WriteLine(b.ToString("x"))
Tu-Thac www.ongtech.co
----- John Sturm wrote: ----
h
how can I convert a byte array to string, so that the bytes appear in hex format in the string. Can anyone help
John
John,
In addition to others comments, I would use a StringBuilder to build the
string of hex digits.
Something like:
Dim bytes() As Byte = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20}
Dim sb As New System.Text.StringBuilder(bytes.Length * 2)
For Each b As Byte In bytes
sb.Append(b.ToString("x2"))
Next
Dim s As String = sb.ToString
Hope this helps
Jay
"John Sturm" <an*******@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.com... hi how can I convert a byte array to string, so that the bytes appear in hex
format in the string. Can anyone help? John
John,
In addition to others comments, I would use a StringBuilder to build the
string of hex digits.
Something like:
Dim bytes() As Byte = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20}
Dim sb As New System.Text.StringBuilder(bytes.Length * 2)
For Each b As Byte In bytes
sb.Append(b.ToString("x2"))
Next
Dim s As String = sb.ToString
Hope this helps
Jay
"John Sturm" <an*******@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.com... hi how can I convert a byte array to string, so that the bytes appear in hex
format in the string. Can anyone help? John
Cor Ligthert <no**********@planet.nl> wrote: Normaly Jon answers this, I did not see him some days, I try it.
Yup - I've been away.
A string is in unicode format, 2Bytes in dotNet programs.
Hang on though - that's not what he's asking for. He's basically asking
for BitConverter.ToString(byte[]).
He wants to *format* a byte array, not *decode* it.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Cor Ligthert <no**********@planet.nl> wrote: Normaly Jon answers this, I did not see him some days, I try it.
Yup - I've been away.
A string is in unicode format, 2Bytes in dotNet programs.
Hang on though - that's not what he's asking for. He's basically asking
for BitConverter.ToString(byte[]).
He wants to *format* a byte array, not *decode* it.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hi Jon, Hang on though - that's not what he's asking for. He's basically asking for BitConverter.ToString(byte[]).
He wants to *format* a byte array, not *decode* it.
I knew also that that could be the question, however really sure was I not
from that because "appear" is not "showed". (The old charactersstrings
where in one byte hex format). I take always the answer on what most people
fits first. It was a try what would be the answer to get that sure.
Cor
Hi Jon, Hang on though - that's not what he's asking for. He's basically asking for BitConverter.ToString(byte[]).
He wants to *format* a byte array, not *decode* it.
I knew also that that could be the question, however really sure was I not
from that because "appear" is not "showed". (The old charactersstrings
where in one byte hex format). I take always the answer on what most people
fits first. It was a try what would be the answer to get that sure.
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Thomas Philips |
last post by:
Consider the following simple dictionary
e={1:'one', 2: 'two'}
e
>>>'one'
However, If I attempt to print e using a formatted string
print " %(1)s" %e,
I get a KeyError: '1'
|
by: Steve Holden |
last post by:
I was messing about with formatting and realized that the right kind of
object could quite easily tell me exactly what accesses are made to the
mapping in a string % mapping operation. This is a...
|
by: ilona |
last post by:
Hi all,
I store phone numbers in the database as 123447775665554(input mask is used
for input, and some numbers have extensions), and I also know from db if the
number is Canadian, US, or some...
|
by: Ken Wilson |
last post by:
I am writing and .xml file and am not getting the formatting I would
like. The portion of the code that is giving me problems is as
follows;
XmlTextWriter tw = new XmlTextWriter(filename);
...
|
by: hope |
last post by:
Hi,
How can I format a string field using Data Formatting Expression property in
datagrid?
For example: format last name from BROWN to Brown.
Thanks
|
by: L. Scott M. |
last post by:
Have a quick simple question:
dim x as string
x = "1234567890"
-------------------------------------------------------
VB 6
dim y as string
|
by: gopal |
last post by:
Hi
I am trying to write to log file but the formatting of string is not
properly aligned in log file result
The results looks some thing like this
OK move.xml Successful
OK ...
|
by: Scott M. |
last post by:
Ok, this is driving me nuts...
I am using VS.NET 2003 and trying to take an item out of a row in a
loosely-typed dataset and place it in a label as a currency. As it is now,
I am getting my...
|
by: Jack |
last post by:
Hi there,
Given a standard .NET string, does anyone know what the regular expression
would be to locate each (optional) formatting item in the string (or more
likely does anyone have a link that...
|
by: Tomasz J |
last post by:
Hello developers,
I bind my TextBox control specyfying a format stored in my application
global ApplicationContext object - it has a static string CurrencyFormat
property.
The problem - this...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |