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. Character array

Character array

Scheduled Pinned Locked Moved C#
data-structures
3 Posts 3 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.
  • G Offline
    G Offline
    GetOn GetGoing
    wrote on last edited by
    #1

    I have string array, I converted that one to char array I am trying to access values of character array and trying to convert them to integer. code follows here string rs="999"; char[] rs1=rs.ToCharArray(); int i; int sum=0; for(i=0;i

    N M 2 Replies Last reply
    0
    • G GetOn GetGoing

      I have string array, I converted that one to char array I am trying to access values of character array and trying to convert them to integer. code follows here string rs="999"; char[] rs1=rs.ToCharArray(); int i; int sum=0; for(i=0;i

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      GetOn&GetGoing wrote: I am getting the address value... Try the following:

      int sum = 0;
      int i = 0;
      string rs = "999";
      char[] rs1 = rs.ToCharArray();
      foreach(char c in rs1)
      {
      i = Convert.ToInt32(c);
      sum += 10 * i;
      Console.WriteLine(sum.ToString());
      }

      - Nick Parker
        My Blog

      1 Reply Last reply
      0
      • G GetOn GetGoing

        I have string array, I converted that one to char array I am trying to access values of character array and trying to convert them to integer. code follows here string rs="999"; char[] rs1=rs.ToCharArray(); int i; int sum=0; for(i=0;i

        M Offline
        M Offline
        Marc Clifton
        wrote on last edited by
        #3

        Why not just: int val=Convert.ToInt32(rs); Marc Latest AAL Article My blog Join my forum!

        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