Hex To Byte - CSharp System

CSharp examples for System:Hex

Description

Hex To Byte

Demo Code

// Licensed under the GPL license.
using System.Globalization;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from   w w w.  j a v  a2 s  .  c  o  m

public class Main{
        public static byte HexToByte(string hex)
        {
            if ((hex.Length > 2) || (hex.Length <= 0))
            {
                throw new ArgumentException("hex must be 1 or 2 characters in length");
            }
            return byte.Parse(hex, NumberStyles.HexNumber);
        }
}

Related Tutorials