Nested if statement

You can nest if statements as follows:


using System;

class Program
{
    static void Main(string[] args)
    {
        int i = 5;
        if (i > 0)
        {
            Console.WriteLine("more than 0");
            if (i > 3)
            {
                Console.WriteLine("more than 3");
            }
            else
            {
                Console.WriteLine("less than 3");

            }
        }
    }
}

The output:


more than 0
more than 3
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.