I\'m adding remote devices to a list as they announce themselves across the network. I only want to add the device to the list if it hasn\'t previously been added.
The
If your requirements are to have no duplicates, you should be using a HashSet.
HashSet.Add will return false when the item already exists (if that even matters to you).
You can use the constructor that @pstrjds links to below (or here) to define the equality operator or you'll need to implement the equality methods in RemoteDevice
(GetHashCode
& Equals
).