Saturday, June 13, 2009

Appending ArrayList to another ArrayList

A friend of mine asked about how to append an ArrayList to another ArrayList in C#. I found out that it's an easy task as long as the type of the ArrayList is the same. Just have to typecast it to ICollection.

ArrayList a = new ArrayList();
a.Add("Array 1");
a.Add("Array 2");

ArrayList b = new ArrayList();
b.Add("Array 3");
b.Add("Array 4");



  1. we do have this in our programming also
    this is one of the basic ways to learn hardcore programming.

  2. Hahaha, u do? I didn't, I only had the simple one, typecasting in primitive data type, in classes. hehehe...

  3. thx your code.

    I have more guess...
    How to access and change arrayList's value of arrayList?

    ArrayList a = new ArrayList();
    ArrayList b = new ArrayList();

    a.Add(b); //right?

    I wanna chang "apple" -> "kiwi"

    How I do?

  4. I don't think it's possible to change the value of an object in an ArrayList without re-adding it. You have to loop through the items and change it manually.



Related Posts

Dual Axis not Working in Tableau

Problem : When creating chart with Dual Axis, Synchronize Axis is disabled and cannot be clicked. Cause : Tableau identified this as ...

About Me

My photo
Is an ordinary unNoticed man, with a little knowledge to share and high dreams to achieve. I'd be glad if I can help others, 'coz the only thing for the triumph of evil is for a good man to do nothing. I like English and Chinese language, and know a little about them. Hence, for me, most things can best be expressed in Chinese, some in English, and the rest in others ^^

About Blog

You can find a lot of debugging and deploying problems while developing applications in .NET and Visual Basic here. There are also some querying tips in SQL and typical source codes which might be useful shared here.

Popular Posts



Follow by Email