2 ms·
Arguably, you might want to specify in some cases. For instance, both List<T> and HashSet<T> implement ICollection<T>.Contains, so code written to the interfac
by emodendroket 10y ago
Arguably, you might want to specify in some cases. For instance, both List<T> and HashSet<T> implement ICollection<T>.Contains, so code written to the interface will work with either. On the other hand, the HashSet implementation runs in constant time and the list implementation runs in linear time. Depending on what you're doing that might make things a lot slower. So you could certainly make an argument that you should just force the caller to pass in a HashSet in the first place, especially if the method is protected or private.