How t store the values in arraylist in c#
-
I am trying to store the values of 5 textbxes of a form fr each user into an arrayList and then iterate through the list fr the details of each usern using a foreach statement. I have a problem in writing the code that implements it. ex: UserId, Fname, Lname, addr, city, state -> save these values into an array list and iterate thrugh the list front and back. _-- Please help me out:confused:
Shashank
-
I am trying to store the values of 5 textbxes of a form fr each user into an arrayList and then iterate through the list fr the details of each usern using a foreach statement. I have a problem in writing the code that implements it. ex: UserId, Fname, Lname, addr, city, state -> save these values into an array list and iterate thrugh the list front and back. _-- Please help me out:confused:
Shashank
Theres alot of way doing this. Least of code way would be: ArrayList lst = new ArrayList(); Foreach( TextBox txt in Form.Controls) { lst.Add(txt.Text); } //now your Arraylist contains all the data in textboxes on the form. Hope it helps you. PS:My C# syntax needs some dusting-off, so the code above may not compile as is - but .NET concept works.