return statement

return statement is used to exit a method. It can pass value out of method.


using System;

class Program
{
    static int add(int i, int j)
    {
        return i + j;
    }
    static void Main(string[] args)
    {
        int result = add(2, 3);
        Console.WriteLine(result);

    }
}

The output:


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