I want my small math program to look really sleek, and by this I mean under the Main
method I have the following methods:
Greet()
UserInput1()
UserI
Cannot convert from method group to int
This error message occurs when you attempt to take a method (without invocation) and pass it as a type. The result
method is expecting two parameters of type int
, but you're attempting to pass it the method, rather than the result of the method invocation.
You need to store the results in a variable, or invoke the methods with the ()
:
Like this:
static void Main(string[] args)
{
Greet();
var first = firstNumber();
var second = secondNumber();
result(first , second );
Console.ReadKey();
}
or this:
static void Main(string[] args)
{
Greet();
result(firstNumber(), secondNumber());
Console.ReadKey();
}