Conversions between complex types and byte arrays.
using System; using System.IO; public class Utils { public static byte[] StringToByteArray(String Source) { char[] CSource = Source.ToCharArray(); byte[] Result = new byte[CSource.Length]; for (Int32 i = 0; i < CSource.Length; i++) Result[i] = Convert.ToByte(CSource[i]); return Result; } public static String ByteArrayToString(byte[] Source) { char[] CSource = new char[Source.Length]; for (Int32 i = 0; i < Source.Length; i++) CSource[i] = Convert.ToChar(Source[i]); return new String(CSource); } }