DotNetKick.com is an open-source project. Please report any bugs and let us know your great suggestions. Currently running svn revision 620 (rss)

Kick Spy!, Kick Zeitgeist and Kick Widgets

41
kicks
published 8 months, 11 days ago, submitted by activa activa 8 months, 11 days ago

blog.activa.be — Did you know there's an alternative way of writing "if .. else if .. else if .. etc.." in C#? You probably do, but if you don't, read on...

Add a comment 5 comments | category: | Views: 21 | Get KickIt image code
tags: | tag it

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:

Comments:
404'd! :D
posted by luciolucio 8 months, 11 days ago
yuck, I would shoot anyone on my team who nested 5+ ternary operators. If you want to get rid of the IF ELSE lists replace it with another construct, not a shortcut to the exact same construct.
posted by vistadb 8 months, 10 days ago
read the comments...went over like walking into a classic cafe and asking where Starbucks is. :-)
posted by wisemx wisemx 8 months, 10 days ago
I am terrified now. I have seen bad code, but......
posted by samdnp 8 months, 9 days ago
You people are hilarious.

What a fuss over a stupid article about a simple language feature that few people know about. The code sample I gave is not complicated, and cleaner than the if-then-else way of writing it, *IN THIS SPECIFIC CASE*. And in this case, even if someone doesn't have a clue about what the ternary operator does, he/she will still capture the meaning of that piece of code, because of the way it is written.

I would never recommend this pattern for performing complex conditional assignments. It's just a piece of code showing the "special" behavior of a right-associative operator such as the ternary operator.
posted by activa activa 8 months, 5 days ago



information Login or create an account to comment on this story
 

Sponsored Link: www.carlist.ie

Search:

Ads via The Lounge