HOWTO: Convert a String to a Byte Array (byte[])


Just so I don’t forget, here is how to convert a string to a byte array:

System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

encoding.GetBytes(yourStringHere)


Comments (1)

  1. Garry Trinder says:

    If you’re dealing with non-English languages you might wanna use UTF8/UTF16?

Skip to main content