 |
| C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 26th, 2010, 02:50 PM
|
|
Authorized User
|
|
Join Date: Nov 2010
Posts: 13
Thanks: 4
Thanked 0 Times in 0 Posts
|
|
difference between for and while loop?
Hi,
What is the difference between for and while loop?
which one is better to use in which condition?
Thanks
|
|

December 28th, 2010, 11:40 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

January 23rd, 2011, 12:14 PM
|
|
Authorized User
|
|
Join Date: Nov 2010
Posts: 13
Thanks: 4
Thanked 0 Times in 0 Posts
|
|
While VS For Loop
Hi
Sir,
While loop is better or for loop is better, Performance wise. ?
Thanks.
|
|

January 23rd, 2011, 12:27 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
It's not about performance; it's about serving different needs....
Imar
|
|

January 24th, 2011, 11:23 AM
|
|
Authorized User
|
|
Join Date: Nov 2010
Posts: 13
Thanks: 4
Thanked 0 Times in 0 Posts
|
|
While VS For Loop
Hi,
Sir, if "while loop" is fulfilling our needs, then why there is another "for loop" and why "for loop" isn't obsolete yet?
Thanks..
|
|

January 24th, 2011, 11:33 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Did you read the first few articles from the Google link I posted earlier? You'll find explanations such as:
Quote:
|
A while loop is very much similar to a for loop except that initialization, checking the boolean condition and incrementing the counter value is done at different steps as shown in the below example, otherwise while loop is same as the for loop.
|
In other words, each loop serves a different need.
Imar
|
|
 |