harish reddy

harish reddy

  • NA
  • 162
  • 33.4k

Method invoking

Jan 29 2018 12:15 AM
 Sir,
 
I am not understanding the below code of method. pls explain. 
 
 
static void PrintNumber(int numberParam)
{
// Modifying the primitive-type parameter
numberParam = 5;
Console.WriteLine("in PrintNumber() method, after " +
"modification, numberParam is: {0}", numberParam);
}
 
Invocation of the method from Main():
 
static void Main()
{
int numberArg = 3;
// Copying the value 3 of the argument numberArg to the
// parameter numberParam
PrintNumber(numberArg);
Console.WriteLine("in the Main() method numberArg is: " +
numberArg);
}
 
 
The result from the above line is printed below:
in PrintNumber() method, after modification, numberParam is: 5
in the Main() method numberArg is: 3
 
1. Pls explain what is method declaration, invocation, argument in simple words.  
 
 
 

Answers (3)