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. Pingback: Mark Gjøl

  2. Pingback: Rosalind

Leave a Reply

Your email address will not be published.