SortedList的使用举例

/*
 * Created by SharpDevelop.
 * User: Administrator
 * Date: 2011-7-12
 * Time: 7:42
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections;

namespace test
{
	class Program
	{
		public static void Main(string[] args)
		{
			//Create a SortedList Object;
			SortedList mySl = new SortedList();
			mySl.Add("0","one");
			mySl.Add("1","two");
			mySl.Add("2","three");
			Console.WriteLine("mySl");
			Console.WriteLine("\tCount:	{0}",mySl.Count);
			Console.WriteLine("\tCapacity:	{0}",mySl.Capacity);
			Console.WriteLine("\tKeys and Values: ");
			PrintKeysAndValues(mySl);
			
			
			Console.Write("Press any key to continue . . . ");
			Console.ReadKey(true);
		}
		public static void PrintKeysAndValues(SortedList myList)
		{
			Console.WriteLine("\t-Key-\t-Value-");
			for (int i = 0;i

/*
This code produces the following output.

mySL
  Count:    3
  Capacity: 16
  Keys and Values:
    -KEY-    -VALUE-
    First:    Hello
    Second:    World
    Third:    !
*/


 

你可能感兴趣的:(dotNet)