C# SortedSet SetEquals

Description

SortedSet SetEquals determines whether the current SortedSet object and the specified collection contain the same elements.

Syntax

SortedSet.SetEquals has the following syntax.


public bool SetEquals(
  IEnumerable<T> other
)

Parameters

SortedSet.SetEquals has the following parameters.

  • other - The collection to compare to the current SortedSet object.

Returns

SortedSet.SetEquals method returns true if the current SortedSet object is equal to other; otherwise, false.

Example


/*from ww  w  .j av  a 2s .  c o m*/
using System;
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("d");
        set1.Add("d");
        
        SortedSet<string> set2 = new SortedSet<string>();
        set2.Add("a");
        set2.Add("b");
        set2.Add("c");
        set2.Add("d");
        
        Console.WriteLine(set1.SetEquals(set2));

    }
}

The code above generates the following result.





















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




HashSet
LinkedList
LinkedListNode
List
Queue
SortedSet
Stack