Do .. While loop in C#?

后端 未结 8 1183
后悔当初
后悔当初 2020-12-18 18:21

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!)

8条回答
  •  再見小時候
    2020-12-18 18:39

    Since you mentioned you were coming from VB.NET, I would strongly suggest checking out this link to show the comparisons. You can also use this wensite to convert VB to C# and vice versa - so you can play with your existing VB code and see what it looks like in C#, including loops and anything else under the son..

    To answer the loop question, you simple want to do something like:

    while(condition)
    {
       DoSomething();
    }
    

    You can also do - while like this:

    do
    {
       Something();
    }
    while(condition);
    

    Here's another code translator I've used with success, and another great C#->VB comparison website. Good Luck!

提交回复
热议问题