SortedSet<T>.GetViewBetween Method (T, T)

.NET Framework (current version)
 

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.

Exception Condition
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);
}

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
Show: