小编R. *_*iff的帖子

InterestRate返回0,我使用的引用来自另一个Form

C#的新手,今天我已经在这里发布了一次,我感谢所有的帮助!我有一个我在Visual Basic中创建的程序.窗体有一个主表-的AccountForm.cs,三道关拍表格- WithdrawlForm.cs,DepositForm.csInterestForm.cs.我有两个类,Account.cs及其派生类SavingsAccount.cs.我试图将InterestRate下面的字符串更改为用户输入的利率InterestForm.此代码位于SavingsAccount类.cs文件中.

     public new string toString()
    {
        return String.Format("Account Number: {0} Balance: {1:C} Interest Rate: {2:P}", AccountNumber, AccountBalance, InterestRate);
    }  
Run Code Online (Sandbox Code Playgroud)

完整的SavingsAccount.cs文件

namespace Assignment_6_third_attempt
{
public class SavingsAccount : Account
{
    private InterestForm interestForm = new InterestForm();

    private double interestRate = 0.0;

    #region Constructors
    public SavingsAccount(int accountNumber)
    {
        base.accountNumber = accountNumber;
    }

    public SavingsAccount() { }
    #endregion

   double InterestRate 
   {
        get { return interestForm.interestRate ; …
Run Code Online (Sandbox Code Playgroud)

c#

3
推荐指数
1
解决办法
47
查看次数

标签 统计

c# ×1