In my absolute lack of genius, I just lost way too much time finally realizing that in C# linq-to-objects removes duplicates when you use Union().

At one point I knew this, but I forgot about it because I never want duplicates, slowly forgetting what Union() was doing.

*This time* however, the duplicates are required and it all goes to crap without them.

Save me, Concat()!

You can run but you can't hide from noobery.


  • 0
    It also does an implicit sort, does order matter?
  • 0
    @bkwilliams it's good to point out. It's never affected me before because I usually do an OrderBy/Descending() if a specific order is needed after the Union().

    Concat() doesn't do any kind of sorting nor duplicate removal, so it's just what I need here.
  • 0
    Hash list and nornal list
    You can easly swich between those.
    Why union tho 🤔
Your Job Suck?
Get a Better Job
Add Comment