Click here to Skip to main content
15,881,588 members
Articles / Programming Languages / C#
Tip/Trick

The Elegant Art of Programming

Rate me:
Please Sign up or sign in to vote.
4.90/5 (3 votes)
21 May 2012CPOL 11.2K   1   5
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)


Written By
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:
Expediteapps


Take a look to my blog
Blog

Comments and Discussions

 
GeneralThoughts Pin
PIEBALDconsult21-May-12 7:29
mvePIEBALDconsult21-May-12 7:29 
GeneralMy vote of 1 Pin
Michael E. Jones21-May-12 3:42
Michael E. Jones21-May-12 3:42 
GeneralRe: My vote of 1 Pin
Juan Pablo G.C.21-May-12 3:47
Juan Pablo G.C.21-May-12 3:47 
GeneralRe: My vote of 1 Pin
Michael E. Jones21-May-12 4:09
Michael E. Jones21-May-12 4:09 
GeneralRe: My vote of 1 Pin
John Brett21-May-12 4:15
John Brett21-May-12 4: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.