Hex String To UInt 32 - CSharp System

CSharp examples for System:Hex

Description

Hex String To UInt 32

Demo Code

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

public class Main{
        public static uint HexStringToUInt32(string pvVal)
        {
            int discarded = 0;
            if (pvVal != null)
            {
                while (pvVal.Length < 8)
                {
                    pvVal = "00" + pvVal;
                }
                if (pvVal.Length != 8)
                {
                    return 0;
                }
                return BitConverter.ToUInt32(ReverseBytes(GetBytes(pvVal, out discarded)), 0);
            }
            return 0;
        }
}

Related Tutorials