Remove Method In ArrayList Class
Syntax for Remove Method is :- Remove(object value)
------------------------------------------------------------------------------------------------------
using System;
using System.Collections;
public class RemoveMethod
{
public static void Main()
{
ArrayList alist = new ArrayList();
Console.WriteLine("Initial Count {0} and Capacity {1} " ,alist.Count,alist.Capacity);
Console.WriteLine("-------------------------------------");
Console.WriteLine("Adding 3 Elements");
alist.Add('A');
alist.Add('B');
alist.Add('F');
Console.WriteLine("Count {0} and Capacity {1}: " ,alist.Count, alist.Capacity);
for(int i=0;i<alist.Count;i++)
{
Console.Write(alist[i] + " ");
}
Console.WriteLine();
Console.WriteLine("-------------------------------------");
Console.WriteLine("Removing 2 Elements");
alist.Remove('A');
alist.Remove('F');
Console.WriteLine("Count {0} and Capacity {1}: " ,alist.Count, alist.Capacity);
foreach(char c in alist)
{
Console.Write(c + " ");
}
}
}
------------------------------------------------------------------------------------------------------
Remove Method In ArrayList Class
Reviewed by Baljeet Singh
on
10:17
Rating:
No comments: