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. Data conversions with char[]'s

Data conversions with char[]'s

Scheduled Pinned Locked Moved C#
5 Posts 4 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.
  • A Offline
    A Offline
    apollo house
    wrote on last edited by
    #1

    Yes christmas was good,and I left my brain in a bottle some where. How do you convert char[] into strings and char[] into numbers ( greater that 10 eg 1234). I can manager sigles chars but the brain isn't fully functioning yet and I got new year to go yet! Thanks.

    A L 2 Replies Last reply
    0
    • A apollo house

      Yes christmas was good,and I left my brain in a bottle some where. How do you convert char[] into strings and char[] into numbers ( greater that 10 eg 1234). I can manager sigles chars but the brain isn't fully functioning yet and I got new year to go yet! Thanks.

      A Offline
      A Offline
      afstorr
      wrote on last edited by
      #2

      to convert char[] into numbers you could loop through it converting each individual char into a number. Each time you move onto the next char you just multiply the number you are creating by 10 and then add the new character to it.

      A 1 Reply Last reply
      0
      • A afstorr

        to convert char[] into numbers you could loop through it converting each individual char into a number. Each time you move onto the next char you just multiply the number you are creating by 10 and then add the new character to it.

        A Offline
        A Offline
        apollo house
        wrote on last edited by
        #3

        Thanks, but their must be better way on carring out a 'atoi' with char arrays in .Net, and still cannot find a way to convert an array of chars which is delimitted into a string.

        T 1 Reply Last reply
        0
        • A apollo house

          Yes christmas was good,and I left my brain in a bottle some where. How do you convert char[] into strings and char[] into numbers ( greater that 10 eg 1234). I can manager sigles chars but the brain isn't fully functioning yet and I got new year to go yet! Thanks.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          int val = int.Parse(new string(myChars)); :)

          Luc Pattyn

          1 Reply Last reply
          0
          • A apollo house

            Thanks, but their must be better way on carring out a 'atoi' with char arrays in .Net, and still cannot find a way to convert an array of chars which is delimitted into a string.

            T Offline
            T Offline
            tgrt
            wrote on last edited by
            #5

            The String class has an overloaded constructor that allows you to pass in a char array. char[] myChars = new char[] {'A', 'B', 'C'}; string myString = new string(myChars); /// "ABC" EDIT: oops missed the other post that points out the string constructor

            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