0% found this document useful (0 votes)
6 views5 pages

Practical 6

The document discusses implementing various collection classes in C# including ArrayList, Hashtable, Stack, Queue, and SortedList. Code examples are provided to demonstrate adding and accessing elements in each collection class. The output from each example is also shown.

Uploaded by

Rajdeepzala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Practical 6

The document discusses implementing various collection classes in C# including ArrayList, Hashtable, Stack, Queue, and SortedList. Code examples are provided to demonstrate adding and accessing elements in each collection class. The output from each example is also shown.

Uploaded by

Rajdeepzala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

FACULTY OF TECHNOLOGY

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

You might also like