Sollicitatievraag bij Jamy Interactive

Explain the difference between the while and for loop. Provide a .NET syntax for both loops ?

Antwoord op sollicitatievraag

Anoniem

9 mrt 2019

Both loops are used when a unit of code needs to execute repeatedly. The difference is that the for loop is used when you know how many times you need to iterate through the code. On the other hand, the while loop is used when you need to repeat something until a given statement is true. The syntax of the while loop in C# is: while (condition [is true]) { // statements } The syntax of the while loop in VB.NET is: While condition [is True] ' statements End While The syntax of the for loop in C# is: for (initializer; condition; iterator) { // statements }