Parameters

The parameters define the input value for a method.

The following code defines a method called add, which adds two int type variables together.

add method has two parameters, a and b. When calling the add method we must provide data for a and b.


using System;

class Program
{
    static int add(int a, int b)
    {
        int result = a + b;
        Console.WriteLine(result);
        return result;
    }

    static void Main(string[] args)
    {
        add(1, 2);
    }
}
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.