Method group is an expression used in the C# standard to describe a group of one or more overloaded methods identified by their common name. In this case, the compiler is referring to apple.Eat
and banana.Eat
method groups.
You need to call your method with a parameter in parentheses following the name of the method. In addition, you need separate dblpercent
variables for the apples and for the bananas:
Console.WriteLine("What Percent of the Apple would you like to eat?");
double dblpercentApple = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("What Percent of the Banana would you like to eat?");
double dblpercentBanana = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("You have " + (apple.Eat(dblpercentApple)) + "% of your apple and " + (banana.Eat(dblpercentBanana)) + "% of your banana left.");
Rather than composing your strings manually with concatenations, you could use formatting, like this:
Console.WriteLine("You have {0}"% of your apple and {1}% of your banana left.", apple.Eat(dblpercentApple), banana.Eat(dblpercentBanana));
This gives your code additional clarity by keeping the template of the string that you write together in a single string.