Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

The Elegant Art of Programming

3.67/5 (2 votes)
21 May 2012CPOL 10.4K  
This is an alternative for The Elegant Art of Programming

Introduction

To resume what's the point, the solution should solve a simple problem in the most "elegant" way by using LINQ.

Check the orginial tip to get the point of this alternative Smile | :)

Using the code 

Well, reading the following code should be straightforward :
C++
List<double> myList = new List<double>();
myList.Add(1.0);
myList.Add(2.0);
myList.Add(1.0);
 
bool differs = (myList.Distinct().Count() > 1);
 
Console.WriteLine( "All numbers are " + (differs? "not": "") + " the same.");

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)