I'm trying to figure out how to split a string with each separator, I've split strings before only I can't remember how to put separator in place. For my program i have to import data and have a bar chart generated from the imported values. The data includes data including company names which obviously may not be 1 word long, and so there are commas in place to separate each 'column'. Here is an example of a line of data:

565800,22796,PHOTO FRAME 3 CLASSIC HANGING,4,07/09/2011 10:23,9.95,14911

Once split I will need to store them in an array for the values to be called on to create the bar chart.

Question author Jurdun | Source



You could use the Split method which allows you to specify the separator that you would like to split by and then it will return an array of strings that are separated by the delimiter:

string s = "565800,22796,PHOTO FRAME 3 CLASSIC HANGING,4,07/09/2011 10:23,9.95,14911";
string[] parts = s.Split(',');

There are also various overloads of this method that you might take a look.

Answer author Darin-dimitrov

Ask about this question here!