Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. converting decimal into hexadecimal

converting decimal into hexadecimal

Scheduled Pinned Locked Moved C#
question
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cyn8
    wrote on last edited by
    #1

    hi, is there any simple way or code that i can use to convert a decimal into a hexadecimal? Thanks in advance:)

    P M G P 4 Replies Last reply
    0
    • C cyn8

      hi, is there any simple way or code that i can use to convert a decimal into a hexadecimal? Thanks in advance:)

      P Offline
      P Offline
      Paras Kaneriya
      wrote on last edited by
      #2

      I dont think there is any inbuilt function for these you need to do it manually :rolleyes:

      Paras Kaneriya
      The difference between genius and stupidity is that genius has its limits.

      1 Reply Last reply
      0
      • C cyn8

        hi, is there any simple way or code that i can use to convert a decimal into a hexadecimal? Thanks in advance:)

        M Offline
        M Offline
        Martin 0
        wrote on last edited by
        #3

        Hello, this[^] looks promising!

        All the best, Martin

        1 Reply Last reply
        0
        • C cyn8

          hi, is there any simple way or code that i can use to convert a decimal into a hexadecimal? Thanks in advance:)

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          There is no direct conversion. First parse the decimal string into a numeric value. Example: string dec = "123"; int num = int.Parse(dec); Then format the number into a string in hexadecimal format. Example: string hex = num.ToString("x"); You can specify the number of digits you want in the hexadecimal number: string hex = num.ToString("x4");

          --- single minded; short sighted; long gone;

          1 Reply Last reply
          0
          • C cyn8

            hi, is there any simple way or code that i can use to convert a decimal into a hexadecimal? Thanks in advance:)

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5
            int value = 15;
            string hex = string.Format("{0:x2}", value);
            Console.WriteLine(hex);
            Console.ReadKey();
            

            Deja View - the feeling that you've seen this post before.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups