Interviews6 answers
In which scenario Hashset is used in C# ?
6 Answers
To get unique values from a collection holding duplicate values
Shweta LodhaPosted Feb 3, 2017, 5:45 PM EST
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 VenkatesanPosted Jun 7, 2016, 10:53 PM EDT
When a collection should have Distinct values then its suggested for Hashset
Bhuvanesh MohankumarPosted May 30, 2016, 9:01 AM EDT
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
Posted Jan 9, 2016, 1:45 AM EST
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 BansodPosted Dec 31, 2015, 2:01 AM EST
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 PatelPosted Dec 31, 2015, 12:04 AM EST




