The Elegant Art of Programming






3.67/5 (3 votes)
This is an alternative for "The Elegant Art of Programming"
Even simpler:
if ( (new HashSet<double> ( myList )).Count == 1 ) ...
Your code pretty much devolves to this anyway.
On the other hand, the first example you provide is probably more efficient, mainly due to the short-circuit. And if you put it in a library function, you just call it and then there's no concern about elegance.