Content Obsolete

This content is no longer current. Our recommendation for up to date content: http://channel9.msdn.com/Series/C-Fundamentals-for-Absolute-Beginners

for Iterations - 08

Download this episode

Download Video

Download captions

Download Captions

Description

Iterations allow our applications to loop through a block of code until a condition is satisfied. We'll cover several different types of iteration statements throughout this series, starting with the for iteration statement. This lesson demonstrates how to utilize "code snippets" to help remind you of the syntax for this complex statement, and shows debugging in action via the values of loops displayed in the Visual Studio IDE.

Download the source code for Iterations

Tags:

C#, Visual Studio

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      santi_m

      Nice

    • User profile image
      George​Neville

      Great video series Bob.

      Here's a nice homework challenge for this lesson that ties back to the lessons on data types.

      Challenge: Modify Bob's code so that the numbers displayed are 1-10 instead of 0-9. Don't forget to modify when 7 is found. I found several ways to do it wrong before I figured out a correct method.

       

    • User profile image
      Tera

      many ways to do it, not sure what way your talking about...

    • User profile image
      George​Neville

      many ways to do it, not sure what way your talking about...

      A way that returns the correct result Wink The point being to try it as it reinforces earlier concepts.

      For example:

      Console.WriteLine(i.ToString()+1);

      Will give you something different. 

    • User profile image
      thens

      Nice One Smiley

    • User profile image
      Erik

      Easiest way to get it to display 1 - 10 is to alter the "for" loop.

    • User profile image
      Skyeblue

      What i wish was explained is why are parenthesis used by themselves vs when do parenthesis rest inside another pair of parenthesis? i.e... console.writeline(message); vs console.writeline (i.toString()); don't think I heard this explained.

    • User profile image
      BobTabor

      @Skyeblue: First of all, KUDOS for being an "active learner" ... for having questions about the content and not just accepting the order I'm presenting the content.  I am an active learner too ... I have to "control" the learning process by asking questions.  So, again, you're doing it right.  Smiley

      Specifically to your question ... You might want to re-watch Lesson 7 on operators wherein I say that the parenthesis operator plays several roles, but when butted right up next to an identifier (like a method name) means that it is used as the method invocation operator ... so:

      executeMe();

      ... will EXECUTE the method.  

      In the examples you used:

      console.writeline()  <--- here we're invoking the writeline method of the console object

      i.ToString() <--- here we're invoking the ToString method of integer objects

      What the heck does all that mean?  In Lessons 10 and 15 we'll talk about methods more.  So, we're getting there!!!  Just hang in there.  Smiley

    • User profile image
      Tyler

      You say thank you at the end of each video, but I should be thanking you!
      So far so good! I'm still rusty on a few things, but with practice, I'm sure I'll get better!

    • User profile image
      BobTabor

      @Tyler: Smiley  Thanks for the kind words.

    • User profile image
      lynda

      Dear Bob,

      First off: your lessons are great! Thank you for that.
      Secondly I still don't understand why there is an ToString in Console.WriteLine(i.ToString) and with the myX example it is not there.
      I recreated your examples and all seems to work either with or without ToString. I am not sure if this is the same question SkyeBlue asked, but I don't think so. Maybe the answer to my question become clear as well later on?

    • User profile image
      lynda

      O nevermind, Bob, I see you answered my question already below video 9. :)

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.