Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 22-11-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Concatenating ArrayLists in C#

How can we concatenate two arraylists in C#? I have tried it but I am not able to find the exact solution and always end up with some or the other error. Please help. This is my second language which I am learning. I have earlier studied HTML (Hyper text Mark-up Language). But it is not at all helpul for me in C#. I am confused and need a solution.
Reply With Quote
  #2  
Old 22-11-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: Concatenating ArrayLists in C#

For me also my first programming language was C-Sharp. And it was not at all easy to grasp all the concepts. My advise to all is to first get yourself educated with C++ and Java. Here is an example for concatenating ArrayLists in C-Sharp.

Code:
System.Collections.ArrayList arrl1 = new System.Collections.ArrayList();
System.Collections.ArrayList arrl2 = new System.Collections.ArrayList();

arrl1.Add("5");
arrl1.Add("10");

arrl2.Add("15");
arrl2.Add("20");
To concatenate we will make use of:
Code:
arrl1.AddRange(arrl2);
Reply With Quote
  #3  
Old 22-11-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: Concatenating ArrayLists in C#

It is very simple first declare the two array lists. Input their respective data. Once done, we can then make use of .AddRange() method of C-Sharp to concatenate the two array lists. Thus, to concatenate arraylists in C-Sharp we make use of the .AddRange() method which simply joints one arraylist to another.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #4  
Old 22-11-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Concatenating ArrayLists in C#

Code:
Dim list1 As New ArrayList()   // declaring first arraylist 
list1.Add("This")
list1.Add("is")
list1.Add("to")
list1.Add("concatenate")

Dim list2 As New ArrayList()     // declaring second arraylist
list2.Add("Arraylist")
list2.Add("in")
list2.Add("C-Sharp")

list1.AddRange(list2)             // concatenate the two array lists
In Csharp we can easily use a .AddRange() to concatenate the two array lists. Csharp helps the developer/ programmer to easily build a .Net framework application. Most of the .Net application are coded in Csharp.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Concatenating ArrayLists in C#"
Thread Thread Starter Forum Replies Last Post
Ignoring ranks when concatenating cells in Microsoft Excel New!life MS Office Support 2 23-02-2012 02:10 PM
Concatenating PDF Documents does not start in Windows 7 little-Jacqueline Operating Systems 5 17-03-2010 04:49 AM
How to use Bubble sort in C# to sort parallel arraylists Ground 0 Software Development 3 03-08-2009 12:12 PM


All times are GMT +5.5. The time now is 08:38 PM.