The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Fun with "for"

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jeff Key

Posts: 481
Nickname: jeffreykey
Registered: Nov, 2003

Jeff Key is legally sane, but questionably competent.
Fun with "for" Posted: Dec 4, 2003 11:40 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Jeff Key.
Original Post: Fun with "for"
Feed Title: Jeff Key
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/jkey/Rss.aspx
Feed Description: Topics revolve around .NET and the Windows platform.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Jeff Key
Latest Posts From Jeff Key

Advertisement

Section 15.8.3 of the C# spec states that the “iterator” portion of the “for” statement “consists of a list of statement-expressions separated by commas”, not simply “Expression statement(s) to increment or decrement the loop counters”, as the MSDN docs proclaim.  I mention this because I don't have a C background (although I did read a great primer in '96) and it's fun to be able to whip out something like the following every once in a while:

for (int i = 0; i < shares.Length; shares[i] = (string)lstShares.SelectedItems[i++]);

True, it's the same as the more legitimate:

for (int i = 0; i < shares.Length;) shares[i] = (string)lstShares.SelectedItems[i++];

But when I do it the first way, I feel like I'm stickin' it to The Man.  I don't know why, and that's probably a good thing.  (Disclaimer:  I don't actually do this “on the job“ since it's not visually parsed easily.)

Read: Fun with "for"

Topic: Project Hurricane Previous Topic   Next Topic Topic: Matrix-soft spoof is there ;-)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use