I have never run into this problem before and I am frustrated. What am I missing? I am trying to initialize an array of five social security numbers. It does fine until the fifth one, then throws an error saying something about the indexer out of bounds.
SSN has to be a string, Also would like help in formatting it as xxx-xx-xxxx. The line I commented out gave me other errors. Thank you.
static void Main(string[] args)
{
// instantiate an array of five (5) Taxpayer objects.
string SSN = "0";
int income = 0;
int tax = 0;
int x = 0;
Taxpayer[] taxArray = new Taxpayer[5];
// Implement a for-loop that will prompt the user to enter the Social Security Number and gross income.
for (x = 0; x <= taxArray.Length; x++)
{
taxArray[x] = new Taxpayer();
Console.Write("Please enter the Social Security Number for taxpayer {0}: ", x);
SSN = Convert.ToString(Console.ReadLine());
//SSN = String.Format("{0:000-00-0000}");
Console.Write("Please enter the gross income for taxpayer {0}: ", x);
income = Convert.ToInt32(Console.ReadLine());
Taxpayer.GetRates();
}