Collections represents group of objects which used to perform various functions such as storing,updaing,retrieving,searching,sorting e.g List<T>
//List e.g
static void Main(string[] args)
{
var student = new List<string>();
student.Add("A");
student.Add("B");
foreach (var item in student)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
stack e.g
static void Main(string[] args)
{
Stack<int> i = new Stack<int>();
i.Push(8);
i.Push(3);
foreach (var item in i)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
// Queue e.g
static void Main(string[] args)
{
Queue<int> i = new Queue<int>();
i.Enqueue(1);
i.Enqueue(2);
i.Enqueue(3);
foreach (var item in i)
{
Console.WriteLine(item);
}
i.Dequeue();
foreach (var item in i)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
List,Queue,stack dulicate element can add
//List e.g
static void Main(string[] args)
{
var student = new List<string>();
student.Add("A");
student.Add("B");
foreach (var item in student)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
stack e.g
static void Main(string[] args)
{
Stack<int> i = new Stack<int>();
i.Push(8);
i.Push(3);
foreach (var item in i)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
// Queue e.g
static void Main(string[] args)
{
Queue<int> i = new Queue<int>();
i.Enqueue(1);
i.Enqueue(2);
i.Enqueue(3);
foreach (var item in i)
{
Console.WriteLine(item);
}
i.Dequeue();
foreach (var item in i)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
List,Queue,stack dulicate element can add
No comments :
Post a Comment