Convert string to byte array with for loop
using System; public sealed class Strings { public static byte[] ToByteArray(string s) { byte[] bs = new byte[s.Length]; for (int i = 0; i < bs.Length; ++i) { bs[i] = Convert.ToByte(s[i]); } return bs; } }