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. string to array

string to array

Scheduled Pinned Locked Moved C#
tutorialdata-structures
6 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.
  • L Offline
    L Offline
    lawrenceinba
    wrote on last edited by
    #1

    hi friends how to convert string to arrays for example "hello world" is given string how to change it in single dimensional array

    the quieter u become more u hear

    L D L 3 Replies Last reply
    0
    • L lawrenceinba

      hi friends how to convert string to arrays for example "hello world" is given string how to change it in single dimensional array

      the quieter u become more u hear

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Depends on the delimiter you want to use:

      string.Split(' ');

      1 Reply Last reply
      0
      • L lawrenceinba

        hi friends how to convert string to arrays for example "hello world" is given string how to change it in single dimensional array

        the quieter u become more u hear

        D Offline
        D Offline
        DaveyM69
        wrote on last edited by
        #3

        string s = "hello world";
        char[] c = s.ToCharArray();

        gives an array of char. If you need an array of strings you can convert from that.

        Dave
        BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
        Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

        L 1 Reply Last reply
        0
        • D DaveyM69

          string s = "hello world";
          char[] c = s.ToCharArray();

          gives an array of char. If you need an array of strings you can convert from that.

          Dave
          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
          Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

          L Offline
          L Offline
          lawrenceinba
          wrote on last edited by
          #4

          thanks

          the quieter u become more u hear

          1 Reply Last reply
          0
          • L lawrenceinba

            hi friends how to convert string to arrays for example "hello world" is given string how to change it in single dimensional array

            the quieter u become more u hear

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

            Hi, if you don't actually need the array and just want to enumerate the characters in a string (without changing them!) you can do:

            string myString="Some string";
            foreach (char myChar in myString) {
            Console.WriteLine("myChar="+myChar);
            }

            PS: please read my signature, I changed it after reading your recent posts. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


            modified on Friday, June 10, 2011 12:03 PM

            L 1 Reply Last reply
            0
            • L Luc Pattyn

              Hi, if you don't actually need the array and just want to enumerate the characters in a string (without changing them!) you can do:

              string myString="Some string";
              foreach (char myChar in myString) {
              Console.WriteLine("myChar="+myChar);
              }

              PS: please read my signature, I changed it after reading your recent posts. :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


              modified on Friday, June 10, 2011 12:03 PM

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Luc Pattyn wrote:

              PS: please read my signature, I changed it after reading your recent posts.

              People like him don't care about such advice :sigh:

              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