-2

In my Windows-Phone application I need to use a condition which needs to run for so long until it is no longer satisfied.

How can I create some form of logic-loop? I have tried using an if statement but that only goes round once.

I'm fairly new to c# and aren't sure of all of the different logic conditions.

Thanks for your help.

Newbie
  • 1,160
  • 2
  • 11
  • 24

1 Answers1

9

You're looking for a while-loop:

while(condition)
{
    // do stuff
}

Or possibly a do-while-loop:

do
{
    // do stuff
} while (condition);

The difference here is that the while-loop always evaluates it's condition before the first iteration while the do-while-loop evaluates it after the first iteration.

Further Reading

p.s.w.g
  • 146,324
  • 30
  • 291
  • 331