Click here to Skip to main content
15,741,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi guys,

pls help me in this.

i have a araylist. i want to store it in a textbox or any string one bye one using for loop.

pls reply ASAP.

This has nothing to do with SQL Server. Also, we don't need to reply 'ASAP', we are happy to help, but we are certainly not required to do your work for you.

You should use List<string> and not ArrayList, which has been obsolete for over a decade.

This[^] is the method you use to take an array and turn it into a single string. But, even

StringBuilder sb = new StringBuilder();

foreach(string s in myArrayList)
  sb.Append(", ");

string result = sb.ToString();

will work. If you don't know how to do that, you should not be using ASP.NET, you should be working through a basic book on C#.
Share this answer
Try like this..

string output = "";
           ArrayList arrayList = new ArrayList();

           arrayList.OfType<string>().ToList().ForEach(k => output += k + ",");

           TextBox1.Text = output;
Share this answer
Christian Graus 6-Jan-14 20:49pm    
The fact he's using ArrayList makes me wonder how old his .NET version is. I doubt he has LINQ.
Karthik_Mahalingam 6-Jan-14 22:00pm    
Christain, people still uses arraylist for storing different datatype objects in a single collection
Christian Graus 6-Jan-14 22:07pm    
He's storing all strings, he said that. And, people may do it, but it's still retarded. If you have a collection of disparate objects, they should be stored in a class. If they have no logical relationship, they probably should not be stored together at all.
Karthik_Mahalingam 6-Jan-14 22:14pm    
god and himself only knows y he is using arraylist instead of list or array ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900