6
Reply

In which scenario Hashset is used in C# ?

Gnanasekaran P

Gnanasekaran P

Dec 29, 2015
2.1k
0

    To get unique values from a collection holding duplicate values

    Shweta Lodha
    February 03, 2017
    0

    HashSet can be used when you dont want set having duplicate values. For example - List dupInts = new List {1,3,4,5,3,3,6}; HashSet noDupInts = new HashSet(dupInts); When this will run - noDupInts will have as {1,3,4,5,6}

    Keerthi Venkatesan
    June 08, 2016
    0

    When a collection should have Distinct values then its suggested for Hashset

    HashSet can be used when you dont want set having duplicate values. For example - List dupInts = new List {1,3,4,5,3,3,6}; HashSet noDupInts = new HashSet(dupInts); When this will run - noDupInts will have as {1,3,4,5,6} Hope this helps

    Kml Surani
    January 09, 2016
    0

    HashSet can be used when you dont want set having duplicate values. For example - List dupInts = new List {1,3,4,5,3,3,6}; HashSet noDupInts = new HashSet(dupInts);When this will run - noDupInts will have as {1,3,4,5,6}Hope this helps

    Vivek Bansod
    December 31, 2015
    0

    HashSet Is used when you want to have a collection with unique elements. HashSet stores list of unique elements and won't allow duplicates in it.

    Ravi Patel
    December 31, 2015
    0