how to get byte array from string?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

is there a quick way to convert string into byte array or do I have to
iterate through and convert each character into a byte?
 
MrNobody said:
is there a quick way to convert string into byte array or do I have to
iterate through and convert each character into a byte?

Use Encoding.GetBytes - and see
http://www.pobox.com/~skeet/csharp/unicode.html for more information
about Unicode. (You can't convert every character into a single byte
unless you are prepared to only handle a subset of possible characters.
That's true for some encodings, but you should be aware that you need
to know what encoding you want to use.)
 

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