Mega Code Archive

 
Categories / C# Book / 01 Language Basics
 

0114 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); } }