Get subset in a SortedSet in CSharp

Description

The following code shows how to get subset in a SortedSet.

Example


using System;/*from w  w w.  j av a2s.com*/
using System.Collections;
using System.Collections.Generic;
using System.IO;


class Program
{
    static void Main(string[] args)
    {
        SortedSet<string> set1 = new SortedSet<string>();
        set1.Add("a");
        set1.Add("b");
        set1.Add("c");
        set1.Add("d");
        
        SortedSet<string> set2 = set1.GetViewBetween("a","c");
        
        foreach (string s in set2)
        {
            Console.WriteLine(s);
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary