Within the loop, look at this line:
Add.FieldName = FieldValue[i].ToString();
FieldValue[i]
can have a maximum
i
of
5, since that's the largest integer that still conforms the loop condition
i < 6
.
But
FieldValue[5] doesn't exist.
FieldValue has 5 members. Arrays are "zero-based" in C# and therefore range from
0 to
4.
How to solve that I have no idea, since I don't know what that code should do. I'm baffled by the arrays
FieldValue
and
CurValue
being both declared with 54 items, but having only 5 defined.
[Edit]
I just checked with VS2008. The declarations of
FieldValue and
CurValue don't even compile.
Drop both occurances of "54". Then, use one of them as loop boundary:
string[] FieldValue = new string[] { "FaName","MoName","Address","HasAE","Misuse" };
string[] CurValue = new string[] { txtFaName.Text, txtMoName.Text, txtAddress.Text, txtHasAE.Text, txtMisuse.Text };
for (int i = 0; i < FieldValue.Length; i++)
{
[/Edit]