c#类错误的最佳重载方法

本文关键字:重载 方法 最佳 错误 | 更新日期: 2023-09-27 17:54:54

public static void BankCharges()
    {
        Console.WriteLine("What is the initial amount in the account?");
        string am = Console.ReadLine();
        double balance = Convert.ToDouble(am);
        Console.WriteLine("How many checks have you made?");
        string ch = Console.ReadLine();
        double checks = Convert.ToDouble(ch);
        double fees = 0.0;
        BankCharges bankcharges = new BankCharges(balance, checks, fees);
        Console.WriteLine("Your final fee for the month is ${0}", bankcharges.GetFees);
    }
class BankCharges
{
    public BankCharges(double balance, double checks, double fees)
    {
        this.Balance = balance;
        this.Checks = checks;
        this.Fees = fees;
    }
    double underfee = 0;
    private double balance;
    public double Balance
    {
        get { return balance; }
        set { balance = value; }
    }
    private double checks;
    public double Checks
    {
        get { return checks; }
        set { checks = value; }
    }
    private double fees;
    public double Fees
    {
        get { return fees; }
        set { fees = value; }
    }
    public double GetFees()
    {
        if (Balance < 400)
        {
            underfee = 15;
        }
        else
        {
            underfee = 0;
        }
        if(checks < 20)
        {
            fees = .10;
        }
        else if (checks < 39 && checks > 20)
        {
            fees = .08;
        }
        else if (checks < 59 && checks > 40)
        {
            fees = .06;
        }
        else if (checks < 0)
        {
            Console.WriteLine("You cannot have a negative amount of checks!");
        }
        else 
        {
            fees = .04;
        }
        double FinalFee = checks*fees + underfee;
        return FinalFee;
    }

我正在做c#的挑战,并且遇到了一些问题。主类(Console. class)的最后一行。WriteLine("你这个月的最终费用是${0}",bankcharges.GetFees);),用红色下划线显示错误信息:最佳重载方法匹配有一些无效参数。有人能帮我修复这个错误吗?

c#类错误的最佳重载方法

GetFees是一个方法调用,但是你没有为它加上括号;

Console.WriteLine("Your final fee for the month is ${0}", bankcharges.GetFees());