// 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 = "14-DA-B9-A3-6D-5F-D6-90"; Console.WriteLine(s); byte[] ba = FromHex(s); string s2 = BitConverter.ToString(ba); Console.WriteLine(s2); } } }