// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Globalization; namespace E { public class Program { public static byte[] FromHex(string s) { byte[] ba = new byte[(s.Length+1)/3]; for(int i = 0; i < ba.Length; i++) { ba[i] = byte.Parse(s.Substring(3 * i, 2), NumberStyles.HexNumber); } return ba; } public static void Main(string[] args) { string s = "1E:04:00:D2:00:01:93:9C"; byte[] ba = FromHex(s); foreach(byte b1 in ba) { Console.WriteLine(b1); } } } }