C# HashSet IsProperSubsetOf

Description

HashSet IsProperSubsetOf determines whether a HashSet object is a proper subset of the specified collection.

Syntax

HashSet.IsProperSubsetOf has the following syntax.


public bool IsProperSubsetOf(
  IEnumerable<T> other
)

Parameters

HashSet.IsProperSubsetOf has the following parameters.

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

Returns

HashSet.IsProperSubsetOf method returns true if the HashSet object is a proper subset of other; otherwise, false.

Example


using System;//w ww. ja va  2s. c o m
using System.Collections.Generic;
public class MainClass{
  public static void Main(String[] argv){  
    HashSet<int> lowNumbers = new HashSet<int>();
    HashSet<int> allNumbers = new HashSet<int>();

    for (int i = 1; i < 5; i++)
    {
        lowNumbers.Add(i);
    }

    for (int i = 0; i < 10; i++)
    {
        allNumbers.Add(i);
    }

    Console.WriteLine(lowNumbers.IsProperSubsetOf(allNumbers));

  }
}

The code above generates the following result.





















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




HashSet
LinkedList
LinkedListNode
List
Queue
SortedSet
Stack