c# - “帐户”不包含“提款”的定义,并且没有可访问的扩展方法“提款”错误
问题描述
完整错误:
“Account”不包含“Withdraw”的定义,并且找不到接受“Account”类型的第一个参数的可访问扩展方法“Withdraw”
using System;
namespace Account
{
class TestAccount
{
public string Name;
public decimal Balance;
public void Account(string Name, decimal Balance)
{
this.Name = Name;
this.Balance = 100;
}
//Accessor
public string getName()
{
return this.Name;
}
public string getBalance()
{
return this.Balance.ToString("C");;
}
//Mutators
public void setName(string Name)
{
this.Name = Name;
}
public void setBalance(decimal Balance)
{
this.Balance = Balance;
}
//Methods
public void Deposit(decimal amount)
{
Console.WriteLine("How much would you like to deposit? Enter an amount: ");
decimal AmountAdded = Convert.ToDecimal(Console.ReadLine());
Balance = amount + AmountAdded;
amount = Balance;
Console.WriteLine("You just added: " + amount.ToString("C"));
}
public void Withdraw(decimal amount)
{
Console.WriteLine("How much would you like to Withdraw? Enter an amount: ");
decimal AmountWithdraw = Convert.ToDecimal(Console.ReadLine());
Balance = amount - AmountWithdraw;
amount = Balance;
Console.WriteLine("You just Withdrew: " + amount.ToString("C"));
}
public void Print()
{
Console.WriteLine("The name of the account is " + Name + "Your Balance is: " + Balance.ToString("C"));
}
}
}
这是我的主要课程
解决方案
推荐阅读
- tensorflow - 用于时间序列预测的编码器解码器
- c - 为什么我在 C malloc 结束时得到一个垃圾值?
- javascript - Why does the script make all the elements work simultaneously and not like they are separate objects
- linux - how to add multiple files in Linker_Flag variable in scilab?
- rest - 有没有办法使用 API 列出拉取请求文件(来自源分支)及其在 Azure Devops 中的位置?还有其他使用 C# 的方法吗?
- python - 如何在unittest python中的startTest()之前运行setup()
- reactjs - 通过 react-router 中的钩子访问 staticContext
- javascript - 是否可以在 innerHtmlin JavaScript 中设置部分文本的样式?
- algorithm - 在 O(nlogn) 时间复杂度中找到总和为 0 的子数组(使用分而治之)?
- r - make.unique 在 R 中重复“唯一”值