Thursday 22 March 2012

SortedList Collection class


//Program of sortedList Of Departments
using System;
using System.Collections;

class Program
{
static void Main()
{
SortedList deptList=new SortedList();

//Adding elements to sorted List
deptList.Add(20,"Sales");
deptList.Add(40,"Admin");
deptList.Add(10,"IT");
deptList.Add(30,"purchase");
deptList.Add(50,"Finance");

//Processing SortedList
foreach(object key in deptList.Keys)
{
string s=(string)deptList[key];
Console.WriteLine("Key: {0}, Value: {1}",key,s);
}
}
}

No comments:

Post a Comment