Integer to Hex

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Al Sav

    Integer to Hex

    Hi,
    I want to convert an integer (actuallu the ascii value of a character) to its equivalent Hex value. Can someone suggest, which is the easiest way to do it.

    Thanks in advance,
    Al.
  • Floyd Burger

    #2
    Re: Integer to Hex

    String.Format( "{0:X2}", intValue)

    --
    Floyd Burger

    "Al Sav" <Al Sav@discussions .microsoft.com> wrote in message
    news:3B98A1B4-F7B5-45B6-B72B-B67F6DF77616@mi crosoft.com...[color=blue]
    > Hi,
    > I want to convert an integer (actuallu the ascii value of a character) to[/color]
    its equivalent Hex value. Can someone suggest, which is the easiest way to
    do it.[color=blue]
    >
    > Thanks in advance,
    > Al.[/color]


    Comment

    • Paul Qualls

      #3
      Re: Integer to Hex

      Al,

      Try something like

      string hexString = String.Format(" {0:x2}", intVal);

      Paul Qualls

      "Al Sav" <Al Sav@discussions .microsoft.com> wrote in message
      news:3B98A1B4-F7B5-45B6-B72B-B67F6DF77616@mi crosoft.com...[color=blue]
      > Hi,
      > I want to convert an integer (actuallu the ascii value of a character) to[/color]
      its equivalent Hex value. Can someone suggest, which is the easiest way to
      do it.[color=blue]
      >
      > Thanks in advance,
      > Al.[/color]


      Comment

      • george r smith

        #4
        Re: Integer to Hex

        for (int i = 0; i < 16; i++)
        Console.WriteLi ne(Convert.ToSt ring(i,16));

        "Al Sav" <Al Sav@discussions .microsoft.com> wrote in message
        news:3B98A1B4-F7B5-45B6-B72B-B67F6DF77616@mi crosoft.com...[color=blue]
        > Hi,
        > I want to convert an integer (actuallu the ascii value of a character) to[/color]
        its equivalent Hex value. Can someone suggest, which is the easiest way to
        do it.[color=blue]
        >
        > Thanks in advance,
        > Al.[/color]


        Comment

        • Beeeeeves

          #5
          Re: Integer to Hex

          string.Format(" 0x{0:x}", i)
          ??




          "Al Sav" <Al Sav@discussions .microsoft.com> wrote in message
          news:3B98A1B4-F7B5-45B6-B72B-B67F6DF77616@mi crosoft.com...[color=blue]
          > Hi,
          > I want to convert an integer (actuallu the ascii value of a character) to[/color]
          its equivalent Hex value. Can someone suggest, which is the easiest way to
          do it.[color=blue]
          >
          > Thanks in advance,
          > Al.[/color]


          Comment

          • Al Sav

            #6
            Re: Integer to Hex

            Thanks for all the response and different methods.

            I ended up using this:
            ((int) c).ToString("x" )

            c is a char.

            I am surprised to see so many different solutions, whereas I was trying so hard to find a solution.
            Alwin S.


            "Beeeeeves" wrote:
            [color=blue]
            > string.Format(" 0x{0:x}", i)
            > ??
            >
            >
            >
            >
            > "Al Sav" <Al Sav@discussions .microsoft.com> wrote in message
            > news:3B98A1B4-F7B5-45B6-B72B-B67F6DF77616@mi crosoft.com...[color=green]
            > > Hi,
            > > I want to convert an integer (actuallu the ascii value of a character) to[/color]
            > its equivalent Hex value. Can someone suggest, which is the easiest way to
            > do it.[color=green]
            > >
            > > Thanks in advance,
            > > Al.[/color]
            >
            >
            >[/color]

            Comment

            Working...