Convert from String to Byte array in C#

To convert from a string to a byte[] in C# use the following code:


byte[] newByteArray = System.Text.Encoding.UTF8.GetBytes("Hello World");

You can use UTF8, UTF16 (Unicode), and UTF32 encoding.

2 Responses to Convert from String to Byte array in C#

  1. Mark Gjøl says:

    Seriously, we need to be IMable so you can come to me with these problems! 🙂

  2. Rosalind says:

    “Convert from String to Byte array in C#

Leave a Reply

Your email address will not be published.