Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Controlling Program Flow in C#

Part of the C# 2010 All-In-One For Dummies Cheat Sheet

The following code segment depicts the great variety of ways in which program flow can be re-routed in C#, including if-else structures, while loops, and for/foreach loops.

if (i < 10)
{
  // go here if i is less than 10
}
else
{
  // go here otherwise
}
while(i < 10)
{
  // keep looping through here as long as i is less than 10
}
for(int i = 0; i < 10; i++)
{
    // loop 10 times
}
foreach(MyClass mc in myCollection)
{
  // ... execute once for each mc object in myCollection
}
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus

SERIES
C# 2010 All-In-One For Dummies Cheat Sheet

Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.