5
Answers

Foreach loop in C#

Photo of Arun Kurmi

Arun Kurmi

12y
1.5k
1
hi friends,
I want to understand following code line by line......... 
private void button1_Click(object sender, EventArgs e)
        {
            label2.Text = "";
            label3.Text = "";
           


            foreach (object checkeditem in checkedListBox1.Items)
            //why we cannot use instead of above line : foreach(CheckedListBox checkeditem in checkedListBox1.Items)
            {
                string str = checkedListBox1.GetItemCheckState(checkedListBox1.Items.IndexOf(checkeditem)).ToString();
//meaning of this line
                if (str == "Checked")
               //why we used "Checked" .
                {
                    label2.Text = label2.Text + checkeditem.ToString() + "\n";
                }
                else
                {
                    label3.Text = label3.Text + checkeditem.ToString() + "\n";
                }
            }

thanks....

Answers (5)

1
Photo of Rajeesh Menoth
NA 24.7k 629.6k 8y
Hi Amit,
 
You can post this add in C# Corner Job section.
 
http://www.c-sharpcorner.com/jobs/recent-jobs
0
Photo of Francis
NA 11.7k 724.3k 8y
This is not a suitable place. Normally in this forum we are discussed about ASP.Net related things.Try to post your question in the relevant category.