'a return keyword must not be followed by object expression

my code is running but the biggest number out of the three numbers that has been entered is not appearing how can I solve this?

this is the code that I have done



Solution 1:[1]

There problem with your code is that the return type of GetMax is void meaning it does not return anything, and you try to return an integer.

You should make the following change:

static int GetMax(int first, int second)
-------^^^
{
    int a;
    if (first > second) a = first;
    else a = second;
    return a;
}

The second problem is that in the Main method you are just calling the GetMax method without doing anything with the max value.

So in main you should also change the following:

int max = GetMax(GetMax(a, b), c);

Console.WriteLine("The biggest number is", max);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kuba Pawlak