CSharp examples for System:Hex
Hex String To UInt
// Licensed under the GPL license. using System.Globalization; using System.Text; using System.Linq; using System.Collections.Generic; using System;//from ww w . j ava2s . c om public class Main{ public static ushort HexStringToUInt16(string pvVal) { ushort num = 0; if (pvVal == null) { return num; } int discarded = 0; if (pvVal.Length == 2) { pvVal = "00" + pvVal; } if (pvVal.Length != 4) { return 0; } num = BitConverter.ToUInt16(GetBytes(pvVal, out discarded), 0); return (ushort)((num >> 8) | (num << 8)); } }