C# SortedSet Contains

Description

SortedSet Contains determines whether the set contains a specific element.

Syntax

SortedSet.Contains has the following syntax.


public virtual bool Contains(
  T item
)

Parameters

SortedSet.Contains has the following parameters.

  • item - The element to locate in the set.

Returns

SortedSet.Contains method returns true if the set contains item; otherwise, false.

Example


using System;//  w  w  w . j a v a 2  s.co m

using System.Collections.Generic;

public class MainClass{
  public static void Main(String[] argv){  
    SortedSet<int> evenNumbers = new SortedSet<int>();
    for (int i = 0; i < 5; i++){
        evenNumbers.Add(i * 2);
    }
    if (evenNumbers.Contains(0))
    {
       evenNumbers.Remove(0);
    }
  }
}




















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




HashSet
LinkedList
LinkedListNode
List
Queue
SortedSet
Stack