Click here to Skip to main content
15,896,259 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
C#
    public class AccumulateSavingsBatch {
    private Bank bank;
    public void setBank(Bank bank)
    {
        this.bank=bank;
    }
    public void doBatch()
    {
        for (Customer c : bank)
        {
            for (Account a : c)
            {
                if(a instanceof SavingAccount)
                {
                    a.accumulateIntersest();
                }
            }
        }
    }
}


foreach not applicable to expression type this error appears with customer and account y??
Posted
Updated 1-Jun-11 2:13am

1 solution

Your Customer and Bank Classes Should Implement the interface IEnumerable<t>.

For each works with the class which implements IEnumerable, IEnumerable<t>, IList, IList<t> etc.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 1-Jun-11 16:24pm    
Sure, a 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900