In some cases a function / method contains only one line in its scope, see the illustrative example:
static int Soma(int a, int b)
{
return a + b;
}
However, the new feature in C # 6.0 which allows declaring a function / method in lambda expression in just one line, see the illustrative example:
static int Subtrai(int a, int b) => a - b;
And the way to call these functions is the same:
var resultadoSoma = Soma(10, 5);
var resultadoSubtracao = Subtrai(10, 9);
WriteLine($"Resultado da soma = {resultadoSoma}\nResultado da subtração = {resultadoSubtracao}");
Output:
Result of sum = 15
Subtraction result = 1
Dotnetfiddle full of the example.
Questions
This gave me the following doubts: