3
I just got into the matter of functions and methods and I’ve come across a problem that I can’t solve at all because I don’t understand why.
The point is:
"Create a method that takes an integer number and tells if it is positive (true) or negative (false) through a return with Boolean."
My code went like this:
class Program
{
static bool PositivoOuNegativo (int Numero, bool Resultado)
{
if (Numero >= 0)
{
Resultado = true;
}
else
{
Resultado = false;
}
return Resultado;
}
static void Main(string[] args)
{
int numeroTeste;
bool ResultadoTeste;
Console.Write("Digite um número: ");
numeroTeste = Convert.ToInt32(Console.ReadLine());
ResultadoTeste = PositivoOuNegativo(numeroTeste);
Console.ReadKey();
}
}
But the error is appearing:
CS7036 There is no argument provided that matches the parameter formal required "Result" of "Program.Positivoounegative(int, bool)".
Where I’m going wrong and how to proceed?
you set the function to receive 2 arguments,
int Numero, bool Resultado
but must have only one, the result is returned by the function at the end of it– Rovann Linhalis