0
When to use a hashset
I am just discovering the hashset in C#. When would one use a hashset and do you want to know if an item is not added to the list. I was thinking about an article list, where it is not allowed to have duplicate items. In this case you need to send feedback to the user prompted him to use another name. Could you do this with a hashset ? Is it preferred ? https://code.sololearn.com/cuGaGplYCj6E
1 Resposta
+ 1
When you adding item to hash Set it return true if it is successful. And returns false if is unsuccessful or already there.. So you can check by if condition and report accordingly..
Edit: oh.. you already know it..
HashSet is preferred when you don't want to allow dublicate..