C# ArrayList Clear
Description
ArrayList Clear
removes all elements from the ArrayList.
Syntax
ArrayList.Clear
has the following syntax.
public virtual void Clear()
Returns
ArrayList.Clear
method returns
Example
using System;/*w w w .j av a 2s. com*/
using System.Collections;
class MainClass
{
static void Main(string[] args)
{
ArrayList a = new ArrayList(10);
int x = 0;
a.Add( ++x);
a.Add( ++x);
a.Add( ++x);
a.Add( ++x);
a.Remove(x);
a.RemoveAt(0);
a.Clear();
}
}
The code above generates the following result.