C# convert a string to a byte array.
public static byte[] StrToByteArray(string str)
{
System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}
//The above function will return the byte array for the given string.
private void button1_Click(object sender, EventArgs e)
{
byte[] b= StrToByteArray(”Hello World”);
}
