Get Substrings

S

shapper

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
 
M

Mark Rae

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(',');
 
M

Mark Rae

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(','));
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top