Do .. While loop in C#?
问题 How do I write a Do .. While loop in C#? (Edit: I am a VB.NET programmer trying to make the move to C#, so I do have experience with .NET / VB syntax. Thanks!) 回答1: The general form is: do { // Body } while (condition); Where condition is some expression of type bool . Personally I rarely write do/while loops - for , foreach and straight while loops are much more common in my experience. The latter is: while (condition) { // body } The difference between while and do...while is that in the