//Generic List Demonstration
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
List<string> list=new List<string>();
list.Add("ASP.NET");
list.Add("C#.NET");
list.Add("VB.NET");
list.Add("Java");
list.Add("Jquery");
PrintList(list);
Console.WriteLine("\nAfter using Insert Statement list is:");
list.Insert(0,"JavaScript");
PrintList(list);
Console.WriteLine("\nAfter using Remove Statement list is:");
list.Remove("JavaScript");
PrintList(list);
Console.WriteLine("\nAfter using Remove At Statement list is:");
list.RemoveAt(1);
PrintList(list);
}
static void PrintList(List<string> list)
{
Console.WriteLine();
foreach(string s in list)
{
Console.Write("{0} ",s);
}
Console.WriteLine();
}
}
No comments:
Post a Comment