What is the best performance optimized alternative to choose among Dictionary<TKey,TValue>
, HashSet<T>
and List<T>
with respect to :
Add values(without duplicates)
LookUps
Delete values.
I have to avoid adding duplicate values to the collection I know HashSet is good, since it skips the add if a duplicate is detected, a dictionary on the other hand throws an exception if a duplicate is found. List will need an additional ifExists check on the existing items before adding the value. But adding values in a HashSet<T>
without duplicates seems to take around 1 min for 10K records. Is there a way to optimize this.