hi,
i want to convert string into arraylist...............
i have a string .......string vaue is str= "12,13,14,15";
now i want convert this string into arraylist..........
like arr={12,13,14,15};
(using c#)

Recommended Answers

All 3 Replies

Use the Split method (member of String) to split the string on commas. The Split method will return an array of Strings.

string str= "12,13,14,15";
string[] strs = str.Split(',');
ArrayList strsList = new ArrayList();
foreach(string s in strs)
strsList.Add(s);

fastest method

string splitme = "foo,bar,feet,meet,meat,skeet";
ArrayList gatherSplit = new ArrayList(splitme.Split(new char[] { ',' }));
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.