How do you get a byte array out of a string in C#? I would like to pass a string to this method.
Encoding.UTF8.GetBytes("abcd");
Encoding.GetBytes method.
Encoding.GetBytes
Use GetBytes( )
Try
public static byte[] StrToByteArray(string str) { System.Text.UTF8Encoding encoding=new System.Text.UTF8Encoding(); return encoding.GetBytes(str); }