Empty statement in C#
In this article we can learn about Empty statement in C#.
Introduction
Empty statement is very simple statement in C#. Empty statement is used where a statement is required and no need to perform an operation. Empty statement is mostly used with while loop with blank body and label statements.
Example
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace emptystat
{
class Empty
{
public bool print()
{
Console.WriteLine("Rahul sharma");
return true;
}
static void Main(string[] args)
{
int i = 0;
Empty r = new Empty();
while (r.print())
{
; //Empty Statement
}
Console.WriteLine("i = {0}", i);
Console.ReadLine();
}
}
}
Program processes infinite loop.
The output of following program