Empty statement is used when you no need to perform an operation where a statement is required. It simple and easy transfers control to the end point of the statement. It is  very useful with while loop with blank body and label statements.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace EmptyStatementExample
{
 class Program
 {
 public bool PrintHello()
 {
 Console.WriteLine("Hello Pawan");
 return true;
 }
 static void Main(string[] args)
 {
 int i = 0;
 Program p = new Program();
 while (p.PrintHello())
 {
 ; //Empty Statement
 }
 Console.WriteLine("i = {0}", i);
 Console.ReadLine();
 }
 }
}

Leave a Reply

Your email address will not be published. Required fields are marked *