//to demonstrate ArrayList Class
using System;
using System.Collections;
class Program
{
public static void Main()
{
ArrayList arr=new ArrayList();
arr.Add("ASP.NET");
arr.Add("C#");
arr.Add("SQL SERVER");
arr.Add("ADO.NET");
arr.Add("JAVA SCRIPT");
arr.Add("JQUERY");
Console.WriteLine("Actual Array");
PrintList(arr);
Console.WriteLine("After adding Element Array is");
arr.Add("VB.NET");
PrintList(arr);
Console.WriteLine("After Inserting Element Array at First Position is");
arr.Insert(0,".NET TECHNOLOGY");
PrintList(arr);
Console.WriteLine("After Removing Element Array JQUERY is");
arr.Remove("JQUERY");
PrintList(arr);
Console.WriteLine("After Removing Element Array at First Position is");
arr.RemoveAt(0);
PrintList(arr);
Console.WriteLine("After Clearing Element Array ");
arr.Clear();
PrintList(arr);
}
public static void PrintList(ArrayList arr)
{
string str;
Console.WriteLine("\n");
foreach(object obj in arr)
{
str=(string)obj;
Console.Write(str+" ");
}
Console.WriteLine("\n");
}
}
No comments:
Post a Comment