Use an if statement that executes a block : If : Statement C# Examples


C# Examples » Statement » If »

 

Use an if statement that executes a block





A code block is a grouping of two or more statements. 
This is done by enclosing the statements between opening and closing curly braces.




    
class  MainClass
{

    public  static  void  Main()
    {

        int  smallNumber  =  5;
        int  bigNumber  =  100;

        if  (bigNumber  <  smallNumber)
        {
            System.Console.Write(bigNumber);
            System.Console.Write("  is  less  than  ");
            System.Console.Write(smallNumber);
        }
        else
        {
            System.Console.Write(smallNumber);
            System.Console.Write("  is  less  than  ");
            System.Console.Write(bigNumber);
        }

    }

}
    
   
  
   



Output

5 is less than 100


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Statement
» If