String to ASCII
using System; public static class StringExtension { public static byte[] ToAscii(this String s) { byte[] retval = new byte[s.Length]; for (int ix = 0; ix < s.Length; ++ix) { char ch = s[ix]; if (ch <= 0x7f) retval[ix] = (byte)ch; else retval[ix] = (byte)'?'; } return retval; } }