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

convert string to array

Scheduled Pinned Locked Moved C#
data-structurestutorialquestion
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.
  • U Offline
    U Offline
    User 9123917
    wrote on last edited by
    #1

    Any idea how can I convert a string to array for the below example: string name = "John,Calvin,Steve"; convert to string [] arr = new string[] {"John","Calvin","Steve"};

    P A P R 4 Replies Last reply
    0
    • U User 9123917

      Any idea how can I convert a string to array for the below example: string name = "John,Calvin,Steve"; convert to string [] arr = new string[] {"John","Calvin","Steve"};

      P Offline
      P Offline
      Peter_in_2780
      wrote on last edited by
      #2

      Start here

      Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

      1 Reply Last reply
      0
      • U User 9123917

        Any idea how can I convert a string to array for the below example: string name = "John,Calvin,Steve"; convert to string [] arr = new string[] {"John","Calvin","Steve"};

        A Offline
        A Offline
        Abhinav S
        wrote on last edited by
        #3

        Use String.Split[^] on the common delimiter character (; in this example).

        A new Windows Phone App - Speed Dial

        1 Reply Last reply
        0
        • U User 9123917

          Any idea how can I convert a string to array for the below example: string name = "John,Calvin,Steve"; convert to string [] arr = new string[] {"John","Calvin","Steve"};

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Just be careful with Split because it will split on delimiters within quotes -- which is not usually desired.

          1 Reply Last reply
          0
          • U User 9123917

            Any idea how can I convert a string to array for the below example: string name = "John,Calvin,Steve"; convert to string [] arr = new string[] {"John","Calvin","Steve"};

            R Offline
            R Offline
            Ramesh Muthiah
            wrote on last edited by
            #5

            string name = "John,Calvin,Steve";
            string [] arr = name.Split(new char[]{','});

            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