csharp System.Collections.SortedList类(方法)实例源码

下面列出了csharp System.Collections.SortedList 类(方法)源码代码实例,从而了解它的用法。

作者:.NET开发    项目:System.Collection   
//引入命名空间
using System;
using System.Collections;
public class SamplesSortedList  {

   public static void Main()  {

      // Creates and initializes a new SortedList.
      SortedList mySL = new SortedList();
       mySL.Add("Third", "!");
       mySL.Add("Second", "World");
       mySL.Add("First", "Hello");

      // Displays the properties and values of the SortedList.
      Console.WriteLine( "mySL" );
      Console.WriteLine( "  Count:    {0}", mySL.Count );
      Console.WriteLine( "  Capacity: {0}", mySL.Capacity );
      Console.WriteLine( "  Keys and Values:" );
      PrintKeysAndValues( mySL );
   }

   public static void PrintKeysAndValues( SortedList myList )  {
      Console.WriteLine( "\t-KEY-\t-VALUE-" );
      for ( int i = 0; i < myList.Count; i++ )  {
         Console.WriteLine( "\t{0}:\t{1}", myList.GetKey(i), myList.GetByIndex(i) );
      }
      Console.WriteLine();
   }
}

作者:.NET开发    项目:System.Collection   
foreach (DictionaryEntry de in mySortedList)
{
    //...
}


问题


面经


文章

微信
公众号

扫码关注公众号