954,206 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

string into arraylist.............very urgent

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#)

gurusamy
Newbie Poster
9 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

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

Ezzaral
Posting Genius
Moderator
15,985 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 
string str= "12,13,14,15";
string[] strs = str.Split(',');
ArrayList strsList = new ArrayList();
foreach(string s in strs)
strsList.Add(s);
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

fastest method

string splitme = "foo,bar,feet,meet,meat,skeet";
ArrayList gatherSplit = new ArrayList(splitme.Split(new char[] { ',' }));
Killer_Typo
Master Poster
781 posts since Apr 2004
Reputation Points: 152
Solved Threads: 39
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You