1 using System; 2 using System.Collections; 3 public class SamplesSortedList { 4 5 public static void Main() { 6 7 // Creates and initializes a new SortedList. 8 SortedList mySL = new SortedList(); 9 mySL.Add("Third", "!"); 10 mySL.Add("Second", "World"); 11 mySL.Add("First", "Hello"); 12 13 // Displays the properties and values of the SortedList. 14 Console.WriteLine( "mySL" ); 15 Console.WriteLine( " Count: {0}", mySL.Count ); 16 Console.WriteLine( " Capacity: {0}", mySL.Capacity ); 17 Console.WriteLine( " Keys and Values:" ); 18 PrintKeysAndValues( mySL ); 19 } 20 21 22 public static void PrintKeysAndValues( SortedList myList ) { 23 Console.WriteLine( "\t-KEY-\t-VALUE-" ); 24 for ( int i = 0; i < myList.Count; i++ ) { 25 Console.WriteLine( "\t{0}:\t{1}", myList.GetKey(i), myList.GetByIndex(i) ); 26 } 27 Console.WriteLine(); 28 } 29 } 30 /* 31 This code produces the following output. 32 33 mySL 34 Count: 3 35 Capacity: 16 36 Keys and Values: 37 -KEY- -VALUE- 38 First: Hello 39 Second: World 40 Third: ! 41 */
构造函数
| SortedList() |
SortedList 对象中的每个键实现)进行排序。 |
| SortedList(IComparer) |
IComparer 接口进行排序。 |
| SortedList(IComparer, Int32) |
IComparer 接口排序。 |
| SortedList(IDictionary) |
IComparable 接口排序。 |
| SortedList(IDictionary, IComparer) |
IComparer 接口排序。 |
| SortedList(Int32) |
SortedList 对象的每个键实现)进行排序。 |
属性
| Capacity |
SortedList 对象的容量。 |
| Count |
SortedList 对象中包含的元素数。 |
| IsFixedSize |
SortedList 对象是否具有固定大小。 |
| IsReadOnly |
SortedList 对象是否为只读。 |
| IsSynchronized |
SortedList 对象的访问是否同步(线程安全)。 |
| Item[Object] |
SortedList 对象中的特定键相关联的值。 |
| Keys |
SortedList 对象中的键。 |
| SyncRoot |
SortedList 对象的访问。 |
| Values |
SortedList 对象中的值。 |
方法
| Add(Object, Object) |
SortedList 对象。 |
| Clear() |
SortedList 对象中移除所有元素。 |
| Clone() |
SortedList 对象的浅表副本。 |
| Contains(Object) |
SortedList 对象是否包含特定键。 |
| ContainsKey(Object) |
SortedList 对象是否包含特定键。 |
| ContainsValue(Object) |
SortedList 对象是否包含特定值。 |
| CopyTo(Array, Int32) |
Array 对象中。 |
| Equals(Object) |
确定指定的对象是否等于当前对象。 (Inherited from Object) |
| GetByIndex(Int32) |
SortedList 对象的指定索引处的值。 |
| GetEnumerator() |
SortedList 对象。 |
| GetHashCode() |
作为默认哈希函数。 (Inherited from Object) |
| GetKey(Int32) |
SortedList 对象的指定索引处的键。 |
| GetKeyList() |
SortedList 对象中的键。 |
| GetType() |
Type。 (Inherited from Object) |
| GetValueList() |
SortedList 对象中的值。 |
| IndexOfKey(Object) |
SortedList 对象中指定键的从零开始的索引。 |
| IndexOfValue(Object) |
SortedList 对象中第一个匹配项的从零开始的索引。 |
| MemberwiseClone() |
Object 的浅表副本。 (Inherited from Object) |
| Remove(Object) |
SortedList 对象中移除带有指定键的元素。 |
| RemoveAt(Int32) |
SortedList 对象的指定索引处的元素。 |
| SetByIndex(Int32, Object) |
SortedList 对象中指定索引处的值。 |
| Synchronized(SortedList) |
SortedList 对象的同步(线程安全)包装。 |
| ToString() |
返回表示当前对象的字符串。 (Inherited from Object) |
| TrimToSize() |
SortedList 对象中元素的实际数目。 |