Click here to Skip to main content
11,924,487 members (63,132 online)
Click here to Skip to main content
Add your own
alternative version


1 bookmarked

The Elegant Art of Programming

, 21 May 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
This is an alternative for "The Elegant Art of Programming"


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:

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);


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


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


About the Author

Juan Pablo G.C.
Software Developer Expediteapps
Spain Spain
I'm Electronic Engineer, I did my end degree project at Astrophysical Institute and Tech Institute. I'm HP Procurve AIS and ASE ,Microsoft 3.5 MCTS
I live in Canary Islands ,developing customized solutions

Deeply involved in Xamarin Forms LOB (including Azure Cloud with offline support, custom controls, dependencies) projects, WP8.1 & W10 projects, WPF modern styled projects. Portable libraries like portablePDF, portableOneDrive, portableReports and portablePrinting (using Google Printing API).

Web and apps showcase at:

Take a look to my blog

You may also be interested in...

Comments and Discussions

GeneralThoughts Pin
PIEBALDconsult21-May-12 8:29
memberPIEBALDconsult21-May-12 8:29 
"not any loops"

Sure there is, it's just buried in the implementation of Linq. The same as if you write a library routine for it.

But, yeah, that's another good alternative. Thumbs Up | :thumbsup:
GeneralMy vote of 1 Pin
Michael E. Jones21-May-12 4:42
memberMichael E. Jones21-May-12 4:42 
GeneralRe: My vote of 1 Pin
Juan Pablo G.C.21-May-12 4:47
memberJuan Pablo G.C.21-May-12 4:47 
GeneralRe: My vote of 1 Pin
Michael E. Jones21-May-12 5:09
memberMichael E. Jones21-May-12 5:09 
GeneralRe: My vote of 1 Pin
John Brett21-May-12 5:15
memberJohn Brett21-May-12 5:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.151125.3 | Last Updated 21 May 2012
Article Copyright 2012 by Juan Pablo G.C.
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid