ArrayList.Insert : ArrayList « System.Collections « C# / C Sharp by API






ArrayList.Insert

  

using System;
using System.Collections;
using System.Collections.Specialized;

class MyClass{
   public string MyName="";   
}

class MainClass
{
  static void Main(string[] args)
  {
    ArrayList classList = new ArrayList();
    classList.AddRange(new MyClass[] { new MyClass(), 
                                           new MyClass(), 
                                           new MyClass()});
    Console.WriteLine("Items in List: {0}", classList.Count);

    classList.Insert(2, new MyClass());
    Console.WriteLine("Items in classList: {0}", classList.Count);

    // Print out current values. 
    foreach(MyClass c in classList)
    {
      Console.WriteLine("MyClass name: {0}", c.MyName);  
    }
  }
}

   
    
  








Related examples in the same category

1.new ArrayList()
2.new ArrayList(Collection c)
3.ArrayList.Add
4.ArrayList.AddRange
5.ArrayList.BinarySearch
6.ArrayList.Capacity
7.ArrayList.Clear()
8.ArrayList.Clone
9.ArrayList.Contains
10.ArrayList.CopyTo
11.ArrayList.GetEnumerator()
12.ArrayList.GetRange
13.ArrayList.IndexOf
14.ArrayList.InsertRange()
15.ArrayList.IsFixedSize
16.ArrayList.IsReadOnly
17.ArrayList.LastIndexOf
18.ArrayList.Remove
19.ArrayList.RemoveAt
20.ArrayList.RemoveRange
21.ArrayList.Reverse()
22.ArrayList.SetRange
23.ArrayList.Sort()
24.ArrayList.Synchronized
25.ArrayList.ToArray
26.ArrayList.ToArray(typeof(T))
27.ArrayList.TrimToSize()