Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7660897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:31:38+00:00 2026-05-31T13:31:38+00:00

I need to have an ability to have unique items in a collection. I

  • 0

I need to have an ability to have unique items in a collection.

I was going to use a Dictionary so I could use the ContainsKey method but I thought it would be a waste as I wouldnt use the Value property of the Key/Value pair.

I came across the HashSet<T> which looks very promising. The only thing I can find that I can’t find in the List<T> docs is that HashSet<T> is unordered. I think that is fine, I assume it means its not ordered using a IEqualityComparer. As long as the order in which items are added are in the same index position I think it will be ok as I have to do duplicate checking hence the hashset and then check all entries are sequential.

Is there anything else I have missed comparing the two types?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:31:38+00:00Added an answer on May 31, 2026 at 1:31 pm

    No, importantly HashSet<T> doesn’t have any concept of ordering or indexing – a list conceptually has slots 0….n-1, whereas a set is “just a set”.

    I think that is fine, I assume it means its not ordered using a IEqualityComparer.

    IEqualityComparer isn’t used for ordering anyway – it only talks about equality and hash codes. HashSet<T> isn’t ordered by either an element comparison (as, say, SortedSet<T> is) or insertion order.

    As long as the order in which items are added are in the same index position I think it will be ok.

    There is no index position, and when you iterate over a HashSet<T> there’s no guarantee you’ll get them back in the order in which you added them. If you’re even thinking about ordering, HashSet<T> isn’t what you’re after.

    Then again, all of this is also true of Dictionary<TKey, TValue> – you shouldn’t make any assumptions about ordering there, either.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have the ability to use superscripts asnd subscripts in a QLineEdit
I need to have ability of using my own java classes in JS, but
I have an app using a SQLite db, and I need the ability for
I need to have ability in my application to be able to export some
I need to have the ability for the user to click a '+' which
My server need to have the ability to handle 10000 request in the same
I have an app that I would like to create. But I am not
I need to do one of two things in Drupal have the ability to
I need to have the ability to convert and merge various documents into a
I need to have the ability to create user accounts on my Linux (Fedora

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.