首页 > 解决方案 > 此方法未实现 c#

问题描述

我是 c# 的新手,我正在为预算应用程序写作。我有我的主课,我的抽象课是我的主课:

  static void Main(string[] args)
    {

        Calculate cal1 = new Calculate();

        cal1.getAmounts();
        
    }

这是我的费用类别:

 abstract class Expense
{
    public abstract double getAmounts();

     public double grossIncome;



  public double estTax;
   public double rent;
    public double deposit;
   public float intRate;
   public double price;
   public int repayMonth;
        public [] monthExps = { "Groceries", "Water and Lights", "Travel costs", "Cell phone and telephone", "Other expenses" };
   

}
class Calculate : Expense
{
    public override double getAmounts()
    {
        

        Console.WriteLine("Enter Gross Income");
        string gI = Console.ReadLine();
        grossIncome = Convert.ToInt32(gI);
        Console.WriteLine("Groceries:" + "R" + grossIncome);

        Console.WriteLine("Enter Estimated Tax");
        string eT = Console.ReadLine();
        estTax = Convert.ToInt32(eT);
        Console.WriteLine("Estimated Tax:" + "R" + estTax);

        Console.WriteLine("Enter Groceries amount");
        string g = Console.ReadLine();
        monthExps[0] = Convert.ToInt32(g);
        Console.WriteLine(":" + "R" + monthExps[0]);

    }
}

我的第一个问题是我试图让用户输入一个数组来存储双精度值。其次,我的公共覆盖双 getAmounts在 getAmounts 下方有一条红线。我的目标是输入值并输出这些值,但是当我运行代码时,我得到 System.NotImplementedException:“方法或操作未实现。” 在这条线上:

Console.WriteLine("Enter Groceries amount");

谁能帮我解决这个错误

标签: c#arraysexceptionuser-input

解决方案


推荐阅读