Why doesn't .Net have a Set data structure?

后端 未结 9 1713
太阳男子
太阳男子 2021-01-19 00:41

One of my biggest issues dealing with a move from Java to .Net is the fact that there isn\'t a Set interface in .Net. I know there are libraries I could go and download but

相关标签:
9条回答
  • 2021-01-19 01:33

    There's HashSet<T> these days, but sadly no interface of which I'm aware.

    0 讨论(0)
  • 2021-01-19 01:33

    I also moved from Java to .Net recently (due to professional employment) and I must admit that my initial problems have also been on collections.
    In the current .Net version (3.5 and speaking about C#) you should orientate yourself on

    • ICollection
    • IList<T>
    • List<T>
    • IDictionary<TKey,TValue>
    • IEnumerable<T>

    These are the most commonly used (hope I didn't miss one)

    0 讨论(0)
  • 2021-01-19 01:36

    Perhaps the reasoning is that a set is really just a list with a particular implementation detail that restricts the items in it to being distinct. Since the distinctness of the list is in the implementation rather than the interface, an interface is not needed.

    As others have mentioned, the FCL has the HashSet<T>.

    0 讨论(0)
提交回复
热议问题