Microsoft 9GD00001 Computer Accessories User Manual


 
102 Microsoft Visual Studio 2010: A Beginner’s Guide
Saving[] savingAccounts = GetSavingAccounts();
foreach (var savingAcct in savingAccounts)
{
savingAcct.Credit(500);
}
}
public Checking[] GetCheckingAccounts()
{
Checking[] chkAccts = new Checking[2];
chkAccts[0] = new Checking();
chkAccts[1] = new Checking();
return chkAccts;
}
public Saving[] GetSavingAccounts()
{
int numberOfAccounts = 5;
Saving[] savAccts = new Saving[numberOfAccounts];
for (int i = 0; i < numberOfAccounts; i++)
{
savAccts[i] = new Saving();
}
return savAccts;
}
VB:
Sub ProcessPayrollForCheckingAndSavingAccounts()
Dim checkAccounts As Checking() = GetCheckingAccounts()
For Each checkAcct In checkAccounts
checkAcct.Credit(500)
Next
Dim savingAccounts As Saving() = GetSavingsAccounts()
For Each savingAcct In savingAccounts
savingAcct.Credit(500)
Next
End Sub