Reputation: 2959
When I try to call the balance method I get the error below.I am trying to list the account holder with their account balance. Any help would be great.
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
public void balance(){
for (int x = 0; x < 6; ++x)
if (x < 5){
Console.WriteLine("Account Holders Name===>{1}Has a balance of===>{2}",
accountname[x], accountbal[x]);
}
}
Upvotes: 0
Views: 13680
Reputation: 70721
Format argument indices start at 0, not 1. Try this:
Console.WriteLine("Account Holders Name===>{0}Has a balance of===>{1}",
accountname[x], accountbal[x]);
Upvotes: 10