none
Naming inconsistency: HashSet.RemoveAll vs List.RemoveWhere RRS feed

  • Question

  • Note that these 2 functions does practically the same thing from the user's standpoint:

    HashSet<T>.RemoveWhere(Predicate<T>)

    List<T>.RemoveAll(Predicate<T>)

    Why do they have 2 different names?

    Friday, April 19, 2019 1:47 PM

Answers

  • Probably because it was written by 2 different developers on the BCL team. Even MS isn't perfect. There are inconsistencies all over the place when you look at the 1000s of types in the framework. HashSet<T> was added in 3.5 whereas List<T> was added in 2.0. Most likely HashSet was an internal type that was promoted to a framework type because of some other dependencies that needed it.

    Since these 2 structures are fundamentally different I have no problems with the names being different. After all the method to remove an item from Stack<T> is Pop whereas for List<T> it is Remove. They are fundamentally the same thing albeit with limits on what can be removed in the case of a stack.


    Michael Taylor http://www.michaeltaylorp3.net

    Friday, April 19, 2019 1:58 PM
    Moderator

All replies

  • Probably because it was written by 2 different developers on the BCL team. Even MS isn't perfect. There are inconsistencies all over the place when you look at the 1000s of types in the framework. HashSet<T> was added in 3.5 whereas List<T> was added in 2.0. Most likely HashSet was an internal type that was promoted to a framework type because of some other dependencies that needed it.

    Since these 2 structures are fundamentally different I have no problems with the names being different. After all the method to remove an item from Stack<T> is Pop whereas for List<T> it is Remove. They are fundamentally the same thing albeit with limits on what can be removed in the case of a stack.


    Michael Taylor http://www.michaeltaylorp3.net

    Friday, April 19, 2019 1:58 PM
    Moderator
  • Hi

    Is your problem solved? If so, please post "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 23, 2019 9:25 AM
    Moderator