I am programming in C# i need to put some things in a string 'xml'
I have the following code
TextBox[] myTextBoxes = new TextBox[] { this.textBox2, this.textBox3, this.textBox4, this.textBox5, this.textBox6, this.textBox7, this.textBox8, this.textBox9, this.textBox10, this.textBox11 };
TextBox[] ValueBoxes = new TextBox[] { this.textBox3, this.textBox5, this.textBox7, this.textBox9, this.textBox11 };
CheckBox[] myCheckBoxes = new CheckBox[] { this.checkBox2, this.checkBox4, this.checkBox6, this.checkBox8, this.checkBox10 };
CheckBox[] myMandBoxes = new CheckBox[] { this.checkBox3, this.checkBox5, this.checkBox7, this.checkBox9, this.checkBox11 };
and to verify certain condition i have
xml += "<fields>";
for (int i = 0; i < myTextBoxes.Length; i++)
{
if (string.IsNullOrWhiteSpace(myTextBoxes[i].Text))
{
if (myCheckBoxes[i].Checked == true)
xml += "<field display='yes'> ";
else
xml += "<field display='no'> ";
if (myMandBoxes[i].Checked == true)
xml += "<mandatory='yes'>";
else
xml += "<Mandatory='no'>";
xml += "<label>" + (string)myTextBoxes[i].Text + "</label>";
}
}
It gives me an Indexoutof boud exception at if (myCheckBoxes[i].Checked == true)
How can i resolve this