I'm having difficulty transitioning to c# from VB in the sense that I don't seem to catch on to For loops and their syntax. I have written several successful programs using them in VB, but it seems more difficult in C#....is there a little trick to remembering the code?
For loops and nested For loops
Page 1 of 15 Replies - 506 Views - Last Post: 22 February 2011 - 05:10 AM
Replies To: For loops and nested For loops
#2
Re: For loops and nested For loops
Posted 21 February 2011 - 06:53 AM
#3
Re: For loops and nested For loops
Posted 21 February 2011 - 07:13 AM
The syntax is very different, but the functionality is still the same.
You have a variable, whether declared in the loop or elsewhere, given a value of 0. The value of that variable is checked against whatever you decide to check it against, in this case is x less than blah, if it is, then increment x and drop into the loop and perform the logic therein. Once the code inside the loop has done it's thing, we drop back to the conditional statement of the loop to check if x is still less than blah. Repeat this process until x is no longer less than blah.
for (int x = 0; x < blah; x++)
{
// do something...
}
You have a variable, whether declared in the loop or elsewhere, given a value of 0. The value of that variable is checked against whatever you decide to check it against, in this case is x less than blah, if it is, then increment x and drop into the loop and perform the logic therein. Once the code inside the loop has done it's thing, we drop back to the conditional statement of the loop to check if x is still less than blah. Repeat this process until x is no longer less than blah.
This post has been edited by Kilorn: 21 February 2011 - 07:14 AM
#4
Re: For loops and nested For loops
Posted 22 February 2011 - 03:43 AM
you can view the stucture of the for loop and how it works
follow this link
http://www.youtube.c...h?v=n2VyNzIOA8Y
This is very easy
for(int [variable] = [value]; [value] <= [initialization number]; [increment value]++)
{
//Do loop until initialization number is reached
}
This guy explains the loop
http://www.youtube.c...h?v=0ru5ZPigtI0
Its better than vb6 loops
Hope this helps
follow this link
http://www.youtube.c...h?v=n2VyNzIOA8Y
This is very easy
for(int [variable] = [value]; [value] <= [initialization number]; [increment value]++)
{
//Do loop until initialization number is reached
}
This guy explains the loop
http://www.youtube.c...h?v=0ru5ZPigtI0
Its better than vb6 loops
Hope this helps
This post has been edited by marinus: 22 February 2011 - 03:56 AM
#5
Re: For loops and nested For loops
Posted 22 February 2011 - 04:49 AM
Hey dude,
This was a help....I know the basics of loops, but there are now {} and all sorts of other differences from VB. This is what I'm in class for I guess huh...I thank you for your help and I might ask a question or two in the future. Have patience...I'm back in school after30 years and I believe my brain is refusing to go quietly!
Thx,
Chris
This was a help....I know the basics of loops, but there are now {} and all sorts of other differences from VB. This is what I'm in class for I guess huh...I thank you for your help and I might ask a question or two in the future. Have patience...I'm back in school after30 years and I believe my brain is refusing to go quietly!
Thx,
Chris
#6
Re: For loops and nested For loops
Posted 22 February 2011 - 05:10 AM
No problem
If my post helped to you please mark " Was This Post Helpful " and rate it
then well all be happy
Thanks
If my post helped to you please mark " Was This Post Helpful " and rate it
then well all be happy
Thanks
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote







|