別のクラスで作成したメソッドから出力を取得して、writelineステートメントの途中に値を返そうとしています。エラー「演算子'+'はタイプ'文字列'および'メソッドグループ'のオペランドに適用できません」は何も実行を停止していますが、エラーを解決するために見つけることができないようです。これは私が見逃している本当に単純なことかもしれませんが、私はまだプログラミングに本当に慣れていないので、おそらく明らかな何かを見逃しています。
public void EatFruits()
{
double dblpercent;
this.MakeFruits();
Console.WriteLine("You have an Apple and a Banana in your fruit garden.");
Console.WriteLine("What Percent of the Apple would you like to eat?");
dblpercent = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("What Percent of the Banana would you like to eat?");
dblpercent = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("You have " + (apple.Eat) + "% of your apple and " + (banana.Eat) + "% of your banana left.");
}
また、他のクラスのEatメソッドのコードは次のとおりです。
public double Eat(double dblpercent)
{
return (PercentFruitLeft-dblpercent);
}
PercentFruitLeftは、値100で初期に設定され、その後、ユーザーが食べたい量を入力するたびに減少しました。