C# SortedSet SortedSet(IEnumerable)

Description

SortedSet SortedSet (IEnumerable ) initializes a new instance of the SortedSet class that contains elements copied from a specified enumerable collection.

Syntax

SortedSet.SortedSet(IEnumerable) has the following syntax.


public SortedSet(
  IEnumerable<T> collection
)

Parameters

  • collection - The enumerable collection to be copied.

Example


using System;//  ww w .ja  v a  2 s .co m
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        MyComparer myComparer = new MyComparer();
        SortedSet<string> allVehicles = new SortedSet<string>(new String[]{});

        allVehicles.Add("A");
        allVehicles.Add("T");
        allVehicles.Add("B");
    }
}

class MyComparer : EqualityComparer<string>
{
    public override bool Equals(string s1, string s2)
    {
        return s1.Equals(s2, StringComparison.CurrentCultureIgnoreCase);
    }
    public override int GetHashCode(string s)
    {
        return base.GetHashCode();
    }
}




















Home »
  C# Tutorial »
    System.Collections.Generic »




HashSet
LinkedList
LinkedListNode
List
Queue
SortedSet
Stack