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.)
 
Back
Top