Practical 6
Practical 6
Information Technology
01IT0605 – .NET TECHNOLOGY- Lab Manual
Practical 6
6. Create a console application to that implements all collection classes.
Code:
ArrayList:
namespace System.Collections.Generic;
internal class Arraylist1
{
public static void Main()
{
ArrayList student = new ArrayList();
student.Add("jackson");
student.Add(5);
for (int i = 0; i < student.Count; i++)
{
Console.WriteLine(student[i]);
}
Console.Write("92210104026 kunjesh_patadiya");
}
}
OUTPUT:
92210104026 6TD2(A) 13
FACULTY OF TECHNOLOGY
Information Technology
01IT0605 – .NET TECHNOLOGY- Lab Manual
Code:
Hashtable:
namespace System.Collections;
internal class Hashtable1
{
public static void Main()
{
Hashtable mytable = new Hashtable();
mytable.Add("name","Ginnay");
mytable.Add("RollNumber", 26);
mytable.Add("Address", "Rajkot");
Console.WriteLine(mytable["RollNumber"]);
Console.Write("92210104026 Kunjesh_patadiya");
}
}
Output:
92210104026 6TD2(A) 14
FACULTY OF TECHNOLOGY
Information Technology
01IT0605 – .NET TECHNOLOGY- Lab Manual
Code:
Stack:
namespace System.Collections;
internal class Stack1
{
public static void Main(string[] args)
{
Stack country = new Stack();
country.Push("USA");
country.Push("India");
foreach (String item in country)
{
Console.WriteLine(item);
}
Console.Write("92210104026 Kunjesh_patadiya");
}
}
Output:
92210104026 6TD2(A) 15
FACULTY OF TECHNOLOGY
Information Technology
01IT0605 – .NET TECHNOLOGY- Lab Manual
Code:
Queue:
namespace System.Collections;
internal class Queue1
{
public static void Main()
{
Queue<string> fruits = new Queue<string>();
fruits.Enqueue("Mango");
fruits.Enqueue("Banana");
foreach (String item in fruits)
{
Console.WriteLine(item);
}
Console.Write("92210104026 Kunjesh_Patadiya ");
}
}
OUTPUT:
92210104026 6TD2(A) 16
FACULTY OF TECHNOLOGY
Information Technology
01IT0605 – .NET TECHNOLOGY- Lab Manual
Code:
SortdeList:
namespace System.Collections;
internal class Queue1
{
public static void Main()
{
SortedList mylist = new SortedList();
mylist.Add(1,"Node JS");
mylist.Add(2,"Express JS");
mylist.Add(3,"React JS");
for (int i = 0; i < mylist.Count; i++)
{
Console.WriteLine("{0}:{1}" ,mylist.GetKey(i), mylist.GetByIndex(i));
}
Console.Write("92210104026 Kunjesh_Patadiya”);
}
}
OUTPUT:
92210104026 6TD2(A) 17