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

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2007
Posts: 9
Reputation: gurusamy is an unknown quantity at this point 
Solved Threads: 0
gurusamy gurusamy is offline Offline
Newbie Poster

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

 
0
  #1
Jul 2nd, 2007
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#)
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,442
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 510
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: string into arraylist.............very urgent

 
0
  #2
Jul 2nd, 2007
Use the Split method (member of String) to split the string on commas. The Split method will return an array of Strings.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: string into arraylist.............very urgent

 
0
  #3
Jul 3rd, 2007
  1. string str= "12,13,14,15";
  2. string[] strs = str.Split(',');
  3. ArrayList strsList = new ArrayList();
  4. foreach(string s in strs)
  5. strsList.Add(s);
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 759
Reputation: Killer_Typo will become famous soon enough Killer_Typo will become famous soon enough 
Solved Threads: 35
Killer_Typo's Avatar
Killer_Typo Killer_Typo is offline Offline
Master Poster

Re: string into arraylist.............very urgent

 
0
  #4
Jul 4th, 2007
fastest method

  1. string splitme = "foo,bar,feet,meet,meat,skeet";
  2. ArrayList gatherSplit = new ArrayList(splitme.Split(new char[] { ',' }));
Dont forget to spread the reputation to those that deserve!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC