Learn C#, VB.net with Samples in 1 Day


while
  1. first, evaluates the expression
  2. second, execution of the body
  3. body may execute 0 or more times
1. While loop with Increment
C# VB.net
using System;
class Program
{
    static void Main()
    {
        int min = 5, max = 10;

        while (min <= max)
        {
            Console.WriteLine(min);
            min++;
        }

        Console.ReadKey();
    }
}                                
Class Program
	Shared Sub Main()
		Dim min As Integer = 5, max As Integer = 10

		While min <= max
			Console.WriteLine(min)
			min += 1
		End While

		Console.ReadKey()
	End Sub
End Class

Output:

5
6
7
8
9
10
Test your .net skills with Quiz