- The fourth lesson: <<The third lesson The first lesson>>
4 - the functions that receive "pass" Barmitr and return value:
We want to write a function its mission, return the value of (the number 10 multiplied by the value that we will send to it as parameter)
This means that the function receives an integer value "int"
And return a numeric value of "int", which is the number 10 multiplied by the value that was passed to the function.
How will be the form of the function؟
static int ForthMethod( int parameter)
{
return 10 * parameter;
}
Where we are at the beginning of the function definition in the first line, before the name of the function we wrote "int" means that the function will return the numerical value of "integer".
And we wrote (int parameter) means that the function will receive the value of "int" type is stored in a variable called parameter.
return 10 * parameter;
Now we have established the function, remained as follows call from within the Main:
int result = thirdMethod(6);
Where we sent a numerical value of the function to be placed instead of the variable "parameter", and of course the value of 6 is optional you can try any number of other.
And the function returns a numerical value, it is stored in the variable "result".
And the full program as follows:
class Program
{
static int ForthMethod( int parameter)
{
return 10 * parameter;
}
static void Main(string[] args)
{
int result = ForthMethod(6);
Console.WriteLine(result);
}
}
And so we explained the difference between the four types of functions ..
Sorry if there are errors................morse
0 comments:
Post a Comment