Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8909163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:21:48+00:00 2026-06-15T03:21:48+00:00

I am programming in C# i need to put some things in a string

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:21:49+00:00Added an answer on June 15, 2026 at 3:21 am

    You don’t have same number of checkboxes as Textboxes so you can’t access them against the same index.
    Your index is starting from 0 to myTextBoxes.Length, if i is going to be greater than 4, then you will get this exception.

    Not really sure what you are trying to do but you can add a check against the length before accessing the element from myCheckBoxes.

    if (i < myCheckBoxes.Length && myCheckBoxes[i].Checked == true)
            xml += "<field display='yes'> ";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently started programming for the iOS Platform but now I need some
I have the following String that I need to parse. I am looking for
I'm pretty new to OOP (and also in PHP programming), and I have some
I have a clue about Object Oriented Programming: I need to have a parent
I have been learning about Delegation and Data Sources for iOS programming and need
I'm new to iOS programming and I need to implement a location aware application.
When programming, I need a way to have more than one clipboard (Vista). I
I'm programming an application in Struts and I need to highlight some reminders in
I have an interesting programming puzzle for you: You will be given two things:
I'm very new to iPhone programming, and I'm currently following tutos to understand the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.