Export (0) Print
Expand All

SortedSet<T>.GetViewBetween Method

Returns a view of a subset in a SortedSet<T>.

Namespace:  System.Collections.Generic
Assembly:  System (in System.dll)

public virtual SortedSet<T> GetViewBetween(
	T lowerValue,
	T upperValue
)

Parameters

lowerValue
Type: T
The lowest desired value in the view.
upperValue
Type: T
The highest desired value in the view.

Return Value

Type: System.Collections.Generic.SortedSet<T>
A subset view that contains only the values in the specified range.

ExceptionCondition
ArgumentException

lowerValue is more than upperValue according to the comparer.

ArgumentOutOfRangeException

A tried operation on the view was outside the range specified by lowerValue and upperValue.

This method returns a view of the range of elements that fall between lowerValue and upperValue, as defined by the comparer. This method does not copy elements from the SortedSet<T>, but provides a window into the underlying SortedSet<T> itself. You can make changes in both the view and in the underlying SortedSet<T>.

The following example uses the GetViewBetween method to list only the AVI files from a sorted set of media file names. The comparer evaluates file names according to their extensions. The lowerValue is "AVI" and the upperValue is only one value higher, "AVJ", to get the view of all AVI files. This code example is part of a larger example provided for the SortedSet<T> class.


// List all the avi files.
SortedSet<string> aviFiles = mediaFiles1.GetViewBetween("avi", "avj");

Console.WriteLine("AVI files:");
foreach (string avi in aviFiles)
{
    Console.WriteLine("\t{0}", avi);
}


.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft