Get Substrings

Discussion in 'ASP .Net' started by shapper, Apr 30, 2007.

  1. shapper

    shapper Guest

    Hello,

    I have a string as follows:

    str = "string,hello,something,new object,london"

    How can I get each substring between commas and add it to a generic
    list of string?

    Thanks,

    Miguel
     
    shapper, Apr 30, 2007
    #1
    1. Advertising

  2. shapper

    Mark Rae Guest

    "shapper" <> wrote in message
    news:...

    > I have a string as follows:
    >
    > str = "string,hello,something,new object,london"
    >
    > How can I get each substring between commas and add it to a generic
    > list of string?


    str = "string,hello,something,new object,london";
    List<string> MyStringList = str.Split(',');

    --
    http://www.markrae.net
     
    Mark Rae, Apr 30, 2007
    #2
    1. Advertising

  3. shapper

    Mark Rae Guest

    "Mark Rae" <> wrote in message
    news:...

    > str = "string,hello,something,new object,london";
    > List<string> MyStringList = str.Split(',');


    Apologies - bit of a brainstorm...

    string str = "string,hello,something,new object,london";
    List<string> MyStringList = new List<string>(str.Split(','));
     
    Mark Rae, Apr 30, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Leandro Pardini

    Binary files, substrings and (un)packing.

    Leandro Pardini, Oct 25, 2003, in forum: Perl
    Replies:
    1
    Views:
    606
    Jim Gibson
    Oct 27, 2003
  2. Markus Dehmann

    regex: How to extract substrings?

    Markus Dehmann, Dec 10, 2005, in forum: Java
    Replies:
    2
    Views:
    810
    IchBin
    Dec 10, 2005
  3. Ying Yang
    Replies:
    9
    Views:
    644
    Mike Wahler
    Sep 27, 2003
  4. mrstephengross

    Compile typedef-ed substrings

    mrstephengross, Apr 4, 2005, in forum: C++
    Replies:
    7
    Views:
    412
  5. Robert Reno

    How to get all possible substrings

    Robert Reno, Jan 26, 2010, in forum: C++
    Replies:
    4
    Views:
    580
    P. Lepin
    Jan 28, 2010
Loading...

Share This Page