mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00] 1.0.5000.0 2.0.0.0 4.0.0.0 Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details. System.Object System.Collections.IDictionary System.ICloneable System.Diagnostics.DebuggerDisplay("Count={Count}") System.Diagnostics.DebuggerTypeProxy(typeof(System.Collections.CollectionDebuggerView)) System.Runtime.InteropServices.ComVisible(true)

For the generic version of this collection, see .

A element can be accessed by its key, like an element in any implementation, or by its index, like an element in any implementation.

A object internally maintains two arrays to store the elements of the list; that is, one array for the keys and another array for the associated values. Each element is a key/value pair that can be accessed as a object. A key cannot be null, but a value can be.

The capacity of a object is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling or by setting the property explicitly.

For very large objects, you can increase the maximum capacity to 2 billion elements on a 64-bit system by setting the enabled attribute of the gcAllowVeryLargeObjects configuration element to true in the run-time environment.

The elements of a object are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves. In either case, a does not allow duplicate keys.

The index sequence is based on the sort sequence. When an element is added, it is inserted into in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object.

Operations on a object tend to be slower than operations on a object because of the sorting. However, the offers more flexibility by allowing access to the values either through the associated keys or through the indexes.

Elements in this collection can be accessed using an integer index. Indexes in this collection are zero-based.

The foreach statement of the C# language (for each in Visual Basic) requires the type of each element in the collection. Since each element of the object is a key/value pair, the element type is not the type of the key or the type of the value. Rather, the element type is . For example:

code reference: Classic SortedList Example#2

The foreach statement is a wrapper around the enumerator, which allows only reading from, not writing to, the collection.

Represents a collection of key/value pairs that are sorted by the keys and are accessible by key and by index.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  Each key must implement the interface to be capable of comparisons with every other key in the object. The elements are sorted according to the implementation of each key added to the .

  The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array.

  If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object.

  This constructor is an O(1) operation.

  Initializes a new instance of the class that is empty, has the default initial capacity, and is sorted according to the interface implemented by each key added to the object.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The elements are sorted according to the specified implementation. If the parameter is null, the implementation of each key is used; therefore, each key must implement the interface to be capable of comparisons with every other key in the object.

  The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array.

  If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object.

  This constructor is an O(1) operation.

  Initializes a new instance of the class that is empty, has the default initial capacity, and is sorted according to the specified interface.

  The implementation to use when comparing keys.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  Each key must implement the interface to be capable of comparisons with every other key in the object. The elements are sorted according to the implementation of each key added to the .

  A object is an example of an implementation that can be passed to this constructor. The new object contains a copy of the keys and values stored in the .

  The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array.

  If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object.

  This constructor is an O() operation, where is the number of elements in .

  Initializes a new instance of the class that contains elements copied from the specified dictionary, has the same initial capacity as the number of elements copied, and is sorted according to the interface implemented by each key.

  The implementation to copy to a new object.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  Each key must implement the interface to be capable of comparisons with every other key in the object. The elements are sorted according to the implementation of each key added to the .

  The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array.

  If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object.

  This constructor is an O() operation, where is .

  Initializes a new instance of the class that is empty, has the specified initial capacity, and is sorted according to the interface implemented by each key added to the object.

  The initial number of elements that the object can contain.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The elements are sorted according to the specified implementation. If the parameter is null, the implementation of each key is used; therefore, each key must implement the interface to be capable of comparisons with every other key in the object.

  The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array.

  If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object.

  This constructor is an O() operation, where is .

  Initializes a new instance of the class that is empty, has the specified initial capacity, and is sorted according to the specified interface.

  The implementation to use when comparing keys.
  The initial number of elements that the object can contain.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The elements are sorted according to the specified implementation. If the parameter is null, the implementation of each key is used; therefore, each key must implement the interface to be capable of comparisons with every other key in the object.

  A object is an example of an implementation that can be passed to this constructor. The new object contains a copy of the keys and values stored in the .

  The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array.

  If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object.

  This constructor is an O() operation, where is the number of elements in .

  Initializes a new instance of the class that contains elements copied from the specified dictionary, has the same initial capacity as the number of elements copied, and is sorted according to the specified interface.

  The implementation to copy to a new object.
  The implementation to use when comparing keys.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  The insertion point is determined based on the comparer selected, either explicitly or by default, when the object was created.

  If already equals , the capacity of the object is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added.

  You can also use the property to add new elements by setting the value of a key that does not exist in the object (for example, myCollection["myNonexistentKey"] = myValue). However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements.

  The elements of a object are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves.

  A key cannot be null, but a value can be.

  This method is an O() operation for unsorted data, where is . It is an O(log ) operation if the new element is added at the end of the list. If insertion causes a resize, the operation is O().

  Adds an element with the specified key and value to a object.

  The key of the element to add. The value of the element to add. The value can be null.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 To be added: an object of type 'int'

  is the number of elements that the object can store. is the number of elements that are actually in the .

  is always greater than or equal to . If exceeds while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements.

  The capacity can be decreased by calling or by setting the property explicitly. When the value of is set explicitly, the internal array is also reallocated to accommodate the specified capacity.

  Retrieving the value of this property is an O(1) operation; setting the property is an O() operation, where is the new capacity.

  Gets or sets the capacity of a object.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void

  is set to zero and references to other objects from elements of the collection are also released.

  remains unchanged. To reset the capacity of the object, call or set the property directly. Trimming an empty sets the capacity of the to the default capacity.

  This method is an O() operation, where is .

  Removes all elements from a object.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object

  A shallow copy of a collection copies only the elements of the collection, whether they are reference types or value types, but does not copy the objects that the references refer to. The references in the new collection point to the same objects that the references in the original collection point to.

  In contrast, a deep copy of a collection copies the elements and everything directly or indirectly referenced by the elements.

  This method is an O() operation, where is .

  Creates a shallow copy of a object.

  A shallow copy of the object.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  The elements of a object are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves.

  implements . It behaves exactly as .

  This method uses a binary search algorithm; therefore, this method is an O(log ) operation, where is .

  Starting with the .NET Framework 2.0, this method uses the collection’s objects’ and methods on to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the parameter on the objects in the collection.

  Determines whether a object contains a specific key.

  true if the object contains an element with the specified ; otherwise, false.

  The key to locate in the object.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  The elements of a object are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves.

  This method behaves exactly as the method.

  This method uses a binary search algorithm; therefore, this method is an O(log ) operation, where is .

  Starting with the .NET Framework 2.0, this method uses the collection’s objects’ and methods on to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the parameter on the objects in the collection.

  Determines whether a object contains a specific key.

  true if the object contains an element with the specified ; otherwise, false.

  The key to locate in the object.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  The values of the elements of the object are compared to the specified value using the method.

  This method performs a linear search; therefore, the average execution time is proportional to . That is, this method is an O() operation, where is .

  Starting with the .NET Framework 2.0, this method uses the collection’s objects’ and methods on to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the parameter on the objects in the collection.

  Determines whether a object contains a specific value.

  true if the object contains an element with the specified ; otherwise, false.

  The value to locate in the object. The value can be null.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  The key/value pairs are copied to the object in the same order in which the enumerator iterates through the object.

  To copy only the keys in the , use SortedList.Keys.CopyTo.

  To copy only the values in the , use SortedList.Values.CopyTo.

  This method is an O() operation, where is .

  Copies elements to a one-dimensional object, starting at the specified index in the array.

  The one-dimensional object that is the destination of the objects copied from . The must have zero-based indexing. The zero-based index in at which copying begins.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 To be added: an object of type 'int'

  Each element is a key/value pair that can be accessed as a object.

  is the number of elements that the object can store. is the number of elements that are actually in the .

  is always greater than or equal to . If exceeds while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements.

  Retrieving the value of this property is an O(1) operation.

  Gets the number of elements contained in a object.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object ``

  The index sequence is based on the sort sequence. When an element is added, it is inserted into in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object.

  This method is an O(1) operation.

  Gets the value at the specified index of a object.

  The value at the specified index of the object.

  The zero-based index of the value to get.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.IDictionaryEnumerator

  The foreach statement of the C# language (for each in Visual Basic) hides the complexity of the enumerators. Therefore, using foreach is recommended, instead of directly manipulating the enumerator.

  Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection.

  Initially, the enumerator is positioned before the first element in the collection. also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of .

  returns the same object until either or is called. sets to the next element.

  If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns false. When the enumerator is at this position, subsequent calls to also return false. If the last call to returned false, is undefined. To set to the first element of the collection again, you can call followed by .

  An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined.

  The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.

  This method is an O(1) operation.

  Returns an object that iterates through a object.

  An object for the object.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object ``

  The index sequence is based on the sort sequence. When an element is added, it is inserted into in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object.

  This method is an O(1) operation.

  Gets the key at the specified index of a object.

  The key at the specified index of the object.

  The zero-based index of the key to get.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.IList

  The returned object is a read-only view of the keys of the object. Modifications made to the underlying are immediately reflected in the .

  The elements of the returned are sorted in the same order as the keys of the .

  This method is similar to the property, but returns an object instead of an object.

  This method is an O(1) operation.

  Gets the keys in a object.

  An object containing the keys in the object.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.IList

  The returned object is a read-only view of the values of the object. Modifications made to the underlying are immediately reflected in the .

  The elements of the returned are sorted in the same order as the values of the .

  This method is similar to the property, but returns an object instead of an object.

  This method is an O(1) operation.

  Gets the values in a object.

  An object containing the values in the object.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  The elements of a object are sorted by the keys either according to a specific implementation specified when the is created, or according to the implementation provided by the keys themselves.

  The index sequence is based on the sort sequence. When an element is added, it is inserted into in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the .

  This method uses a binary search algorithm; therefore, this method is an O(log ) operation, where is .

  Starting with the .NET Framework 2.0, this method uses the collection’s objects’ and methods on to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the parameter on the objects in the collection.

  Returns the zero-based index of the specified key in a object.

  The zero-based index of the parameter, if is found in the object; otherwise, -1.

  The key to locate in the object.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  The index sequence is based on the sort sequence. When an element is added, it is inserted into in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object.

  The values of the elements of the are compared to the specified value using the method.

  This method uses a linear search; therefore, this method is an O() operation, where is .

  Starting with the .NET Framework 2.0, this method uses the collection’s objects’ and methods on to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the parameter on the objects in the collection.

  Returns the zero-based index of the first occurrence of the specified value in a object.

  The zero-based index of the first occurrence of the parameter, if is found in the object; otherwise, -1.

  The value to locate in the object. The value can be null.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean To be added: an object of type 'bool'

  A collection with a fixed size does not allow the addition or removal of elements after the collection is created, but does allow the modification of existing elements.

  A collection with a fixed size is simply a collection with a wrapper that prevents adding and removing elements; therefore, if changes are made to the underlying collection, including the addition or removal of elements, the fixed-size collection reflects those changes.

  Retrieving the value of this property is an O(1) operation.

  Gets a value indicating whether a object has a fixed size.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean To be added: an object of type 'bool'

  A collection that is read-only does not allow the addition, removal, or modification of elements after the collection is created.

  A collection that is read-only is simply a collection with a wrapper that prevents modifying the collection; therefore, if changes are made to the underlying collection, the read-only collection reflects those changes.

  Retrieving the value of this property is an O(1) operation.

  Gets a value indicating whether a object is read-only.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean To be added: an object of type 'bool'

  To guarantee the thread safety of a object, all operations must be done through the wrapper returned by the method.

  Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

  Gets a value indicating whether access to a object is synchronized (thread safe).

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object `` To be added: an object of type 'object' To be added To be added: an object of type 'object' To be added
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.ICollection To be added: an object of type 'ICollection'

  The object is a read-only view of the keys of the object. Modifications made to the underlying are immediately reflected in the .

  The elements of the are sorted in the same order as the keys of the .

  This property is similar to the method, but returns an object instead of an object.

  This method is an O(1) operation.

  Gets the keys in a object.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  If the object does not contain an element with the specified key, the remains unchanged. No exception is thrown.

  In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table.

  This method is an O() operation, where is .

  Removes the element with the specified key from a object.

  The key of the element to remove.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  The index sequence is based on the sort sequence. When an element is added, it is inserted into in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object.

  In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table.

  This method is an O() operation, where is .

  Removes the element at the specified index of a object.

  The zero-based index of the element to remove.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  The index sequence is based on the sort sequence. When an element is added, it is inserted into in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object.

  This method is an O(1) operation.

  Replaces the value at a specific index in a object.

  The zero-based index at which to save . The to save into the object. The value can be null.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.SortedList ``

  To guarantee the thread safety of a object, all operations must be done through this wrapper only.

  Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

  Returns a synchronized (thread-safe) wrapper for a object.

  A synchronized (thread-safe) wrapper for the object.

  The object to synchronize.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object To be added: an object of type 'object'

  To create a synchronized version of the object, use the method. However, derived classes can provide their own synchronized version of the using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object.

  Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

  Gets an object that can be used to synchronize access to a object.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.IEnumerator

  [Visual Basic, C#]

  The foreach statement of the C# language (for each in Visual Basic) hides the complexity of the enumerators. Therefore, using foreach is recommended, instead of directly manipulating the enumerator.

  Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection.

  Initially, the enumerator is positioned before the first element in the collection. also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of .

  returns the same object until either or is called. sets to the next element.

  If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns false. When the enumerator is at this position, subsequent calls to also return false. If the last call to returned false, calling throws an exception. To set to the first element of the collection again, you can call followed by .

  An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated.

  The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

  This method is an O(1) operation.

  Returns an that iterates through the .

  An for the .

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void

  This method can be used to minimize a collection's memory overhead if no new elements will be added to the collection.

  To reset a object to its initial state, call the method before calling . Trimming an empty sets the capacity of the to the default capacity.

  This method is an O() operation, where is .

  Sets the capacity to the actual number of elements in a object.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Collections.ICollection To be added: an object of type 'ICollection'

  The object is a read-only view of the values of the object. Modifications made to the underlying are immediately reflected in the .

  The elements of the are sorted in the same order as the values of the .

  This property is similar to the method, but returns an object instead of an object.

  This method is an O(1) operation.

  Gets the values in a object.