C# Using child class methods on an array of objects : <p>I'm sure I'm missing something minor but I can't for the life of me figure it out. I'm trying to use the child class method CalculateInterest for child class SavingsAccount and the child class property TransactionFee for the child class CheckingAccount in the below script. Basically, the test program should loop through each object in the array and depending upon whether the object is a CheckingAccount or SavingsAccount state the interest earned or the transaction fee charged.</p>

<p>The error I get is that CalculateInterest() and TransactionFee are not defined in class Account.</p>

<pre><code>using System;

class BankAccountTester {

    static void Main() {

    Account[] accounts = new Account[4];
    accounts[0] = new SavingsAccount(25, 3);    
    accounts[1] = new CheckingAccount(80, 1);
    accounts[2] = new SavingsAccount(200, 1.5);
    accounts[3] = new CheckingAccount(400, 0.5);

        for (int i = 0; i &lt; 4; i++) {

            double amount;
            string entryString;
            bool check = false;

            Console.WriteLine("Enter an amount to withdraw from Account " + i );
            entryString = Console.ReadLine();
            check = double.TryParse(entryString, out amount);

            while (check == false) {

                Console.WriteLine("Invalid entry. Please specify an amount to withdraw from Account " + i);
                entryString = Console.ReadLine();
                check = double.TryParse(entryString, out amount);

            }

            accounts[i].Debit(amount);

            Console.WriteLine("Enter an amount to deposit into Account " + i);
            entryString = Console.ReadLine();
            check = double.TryParse(entryString, out amount);

            while (check == false) {

                Console.WriteLine("Invalid entry. Please specify an amount to deposit into Account " + i);
                entryString = Console.ReadLine();
                check = double.TryParse(entryString, out amount);

            }

            accounts[i].Credit(amount);

            if (accounts[i] is SavingsAccount) {

                Console.WriteLine("This is a savings account.");

                double interestEarned = accounts[i].CalculateInterest();

                Console.WriteLine("Adding {0} interest to Account {2} (Savings Account)", interestEarned, i);

            }

            else {

                Console.WriteLine("This is a checking account.");

                Console.WriteLine("{0} transaction fee charged.", accounts[i].TransactionFee);

            } 


        }

    }

}

class Account {

    private double balance;

    public double Balance { 

        get {

            return balance;

        }

        set {

            if (value&lt;0) {
                balance = 0;
            }

            else balance = value;

        }

    }

    public Account(double initBalance) {

        Balance = initBalance;

    }

    public void Credit(double amount) {

        Balance = Balance + amount;

    }

    public void Debit(double amount) {

        if (amount&gt;Balance) {

            Console.WriteLine("Amount exceeds account balance.");

        }
        else Balance = Balance - amount;

    }

}

class SavingsAccount : Account {

    private double interestRate;
    private double interestEarned;

    public SavingsAccount(double initBalance, double interest) : base(initBalance) {

        interestRate = interest/100;

    }

    public double CalculateInterest() {

            interestEarned = Balance*interestRate;
            return interestEarned;

    }
}

class CheckingAccount : Account {

    private double transactionFee;

    public double TransactionFee {

        get {
            return transactionFee;
        }

        set {
            transactionFee = value;
        }
    }

    public CheckingAccount(double initBalance, double fee) : base(initBalance) {

        TransactionFee = fee;

    } 

    public new void Credit(double amount) {

        Balance = Balance + amount;
        Balance = Balance - TransactionFee;

    }

    public new void Debit(double amount) {

        bool check;

        if (amount&gt;Balance) {

            Console.WriteLine("Amount exceeds account balance.");
            check = false;

        }
        else {

            Balance = Balance - amount;
            check = true;
        }

        if (check == true) {
            Balance = Balance - TransactionFee;
        }
        else Balance = Balance;
    }

}
</code></pre>
