3
Reply

C# help for student - format exception

Amber Porter

Amber Porter

Feb 4 2008 6:05 PM
2.4k

O.k. I'm trying to write a program for school.  the code below (I'm not posting the whole program unless you need to see it) is giving me a format exception when it hits the deptarray line?? Any ideas why???  It's reading data in from a file.  It looks just like the code that was in the teacher's example??  Any help would be appreciated as I"m pulling my hair out.

static void ParseLineIn(string lineIn, uint i)

{

string[] words = new string[5];

lineIn = lineIn.Trim();

while (Regex.IsMatch(lineIn, "[ ] {2}"))

lineIn = lineIn.Replace(" ", " ");

words = lineIn.Split(' ');

lastNameArray[i] = words[0];

firstNameArray[i] = words[1];

deptArray[i] = UInt32.Parse(words[2]);

rateArray[i] = Double.Parse(words[3]);

hoursArray[i] = Double.Parse(words[4]);

}

static void InputEmployeeData()

{

uint i;

string lineIn;

i = 0;

while ((lineIn = fileIn.ReadLine()) != null)

{

i++;

ParseLineIn(lineIn, i);

}

numOfEmployees = i;

}


Answers (3)