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

The Elegant Art of Programming

4.90/5 (3 votes)
21 May 2012CPOL 11.7K  
This is an alternative for The Elegant Art of Programming

Introduction

I thought that the tip was really more interesting, but please do not use such title and then depress myself with that.

An elegant solution is:

C#
List<int> myList = new List<int>() {1,2,1};

Console.WriteLine("All numbers are{0} the same",
        myList.Any((i) => i != myList[0])? " not":String.Empty);

Console.ReadKey();

Just a line, not any loops, and multiple unnecessary stuff.

License

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