0% found this document useful (0 votes)
5 views2 pages

Collections

The document contains C# code demonstrating the use of Dictionary, SortedList, and List collections. It shows how to add, remove, and display elements in these collections, including examples of adding file extensions with their associated applications and managing a list of double values. Additionally, it mentions Stack and Queue, suggesting further exploration of these data structures.

Uploaded by

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

Collections

The document contains C# code demonstrating the use of Dictionary, SortedList, and List collections. It shows how to add, remove, and display elements in these collections, including examples of adding file extensions with their associated applications and managing a list of double values. Additionally, it mentions Stack and Queue, suggesting further exploration of these data structures.

Uploaded by

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

// Dict and SortedList

using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;

namespace Developers
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, string> openWith = new Dictionary<string, string>();
openWith.Add("txt", "notepad.exe");
openWith.Add("bmp", "paint.exe");
openWith.Add("dib", "paint.exe");
openWith.Add("rtf", "wordpad.exe");

foreach(KeyValuePair<string, string> pair in openWith)


{
Console.WriteLine(pair.Key +" => "+pair.Value);
}

Console.WriteLine(new string('*',20));

SortedList<string, string> sopenWith = new SortedList<string,


string>();
sopenWith.Add("txt", "notepad.exe");
sopenWith.Add("bmp", "paint.exe");
sopenWith.Add("dib", "paint.exe");
sopenWith.Add("rtf", "wordpad.exe");

foreach (KeyValuePair<string, string> pair in sopenWith)


{
Console.WriteLine(pair.Key + " => " + pair.Value);
}
}
}
}

List;
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;

namespace Developers
{
class Program
{
static void Main(string[] args)
{
List<double> numbers = new List<double>();

numbers.Add(10.34);
numbers.AddRange(new double[4] { 1.34, 45.67,11.234, 123.5});

Console.WriteLine(numbers.Count);
Console.WriteLine(numbers.Contains(1.34));
numbers.Remove(10.34);

foreach(double number in numbers)


{
Console.Write(number +" ");
}
}
}
}

Stack and Queue

You might also like