else branch

if statement can have an else branch.

The following code prints out There is the value is less than 0.


using System;

class Program
{
    static void Main(string[] args)
    {
        int i = -1;

        if (i > 0)
        {
            Console.WriteLine("Here");
        }
        else
        {
            Console.WriteLine("There");
        }

    }
}

The output:


There
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.