I found myself with this issue recently and though I've always used the same code to find distinct primitives (before we had the Set object), this code required me to adhere to the C# API where you pass in a comparison function T -> T -> boolean. This solution felt relatively clean though obviously not in linear time.
T -> T -> boolean
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.