Chuyển từ string sang byte array

Using UTF8 conversion

byte[] bArray = Encoding.UTF8.GetBytes (inputString);

Using ASCII conversion

byte[] bArray = Encoding.ASCII.GetBytes (inputString);

Chuyển từ byte array sang string

var str = System.Text.Encoding.Default.GetString(result);
string result = System.Text.Encoding.UTF8.GetString(byteArray);