Click or drag to resize
OrderedDictionaryTKey, TValueRange Method
Returns a collection that can be used for enumerating some of the keys and values in the collection. Only keys that are greater than from and less than to are included. The keys are enumerated in sorted order. Keys equal to the end points of the range can be included or excluded depending on the fromInclusive and toInclusive parameters.

Namespace: X3Platform.Collections
Assembly: X3Platform.Support (in X3Platform.Support.dll) Version: 1.0.0.0 (2.0.0.0)
Syntax
public OrderedDictionaryTKey, TValueView Range(
	TKey from,
	bool fromInclusive,
	TKey to,
	bool toInclusive
)

Parameters

from
Type: TKey
The lower bound of the range.
fromInclusive
Type: SystemBoolean
If true, the lower bound is inclusive--keys equal to the lower bound will be included in the range. If false, the lower bound is exclusive--keys equal to the lower bound will not be included in the range.
to
Type: TKey
The upper bound of the range.
toInclusive
Type: SystemBoolean
If true, the upper bound is inclusive--keys equal to the upper bound will be included in the range. If false, the upper bound is exclusive--keys equal to the upper bound will not be included in the range.

Return Value

Type: OrderedDictionaryTKey, TValueView
An OrderedDictionary.View of key-value pairs in the given range.
Remarks

If from is greater than or equal to to, the returned collection is empty.

The sorted order of the keys is determined by the comparison instance or delegate used to create the dictionary.

Typically, this property is used in conjunction with a foreach statement. For example:

foreach(KeyValuePair<TKey, TValue> pair in dictionary.Range(from, true, to, false)) {
   // process pair
}

Calling Range does not copy the data in the dictionary, and the operation takes constant time.

See Also