Click here to Skip to main content
Click here to Skip to main content

The Elegant Art of Programming

By , 21 May 2012
 

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:

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)

About the Author

Juan Pablo G.C.
Software Developer
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
 
I'm developing with WPF4, SL4 MVVM, MVC3 Razor and WP7 projects, more info at my websites. Improving with Android and IOS.
 
Websites:
MemCards
Mareinsula


Take a look to my blog Juan Pablo G.C.
Mareinsula

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralThoughts PinmemberPIEBALDconsult21-May-12 7:29 
GeneralMy vote of 1 [modified] PinmemberMichael E. Jones21-May-12 3:42 
GeneralRe: My vote of 1 PinmemberJuan Pablo G.C.21-May-12 3:47 
I think my debugger tells me more in the stack trace than your wisdom Smile | :) . What does not work?
Juan Pablo G.C.
Mareinsula Blog
 

GeneralRe: My vote of 1 PinmemberMichael E. Jones21-May-12 4:09 
GeneralRe: My vote of 1 PinmemberJohn Brett21-May-12 4:15 

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

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

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