Addition Method Within Main Class by Calling method In C#

The method definition specifies the names and types of any parameters that are required. When calling code calls the method, it provides concrete values called arguments for each parameter. The arguments must be compatible with the parameter type but the argument name (if any) used in the calling code does not have to be the same as the parameter named defined in the method.
  1. using System;  
  2. class MethodCalling  
  3. {  
  4.     public static void Main(string[] args)   
  5.     {  
  6.         int value1 = 0, value2 = 0;  
  7.         int total = 0;  
  8.         Console.Write("Enter first value: ");  
  9.         value1 = Convert.ToInt32(Console.ReadLine());  
  10.         Console.Write("Enter second value: ");  
  11.         value2 = Convert.ToInt32(Console.ReadLine());  
  12.         total = addition(value1, value2);  
  13.         Console.WriteLine("Total of {0} and {1} is {2}", value1, value2, total);  
  14.     }  
  15.     static int addition(int x, int y)   
  16.     {  
  17.         return x + y;  
  18.     }  
  19. }  
Output
 
Enter first value: 4
Enter second value: 5
Total of 4 and 5 is 9