convert HEX string into integer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • :)

    #1

    convert HEX string into integer

    Hi all:

    I have a HEX string such as 0x0010026AB0, I can I convert it into an
    integer in C#. Does it have some build-in function.

    Thanks in advance.

  • AlanT

    #2
    Re: convert HEX string into integer



    You can use the Int32.Parse() method if you drop off the leading "0x"

    e.g.
    string val = "0010026AB0 ";
    int inVal = System.Int32.Pa rse(val,
    System.Globaliz ation.NumberSty les.AllowHexSpe cifier);
    MessageBox.Show (inVal.ToString ());

    hth,
    Alan.

    Comment

    • Markus Stoeger

      #3
      Re: convert HEX string into integer

      :) wrote:[color=blue]
      > Hi all:
      >
      > I have a HEX string such as 0x0010026AB0, I can I convert it into an
      > integer in C#. Does it have some build-in function.[/color]

      If you could remove the leading 0x you could use:

      int a = int.Parse("1002 6AB0", NumberStyles.Al lowHexSpecifier );

      hth,
      Max

      Comment

      • :)

        #4
        Re: convert HEX string into integer

        Thanks guys!

        Comment

        Working...