Vikas Ahlawat

Vikas Ahlawat

  • NA
  • 564
  • 817k

what is my mistake?

Oct 24 2009 7:52 AM
for (int i = 2; i <= SCdataGridView1.Rows.Count;i++)
            {
                int malecount = 0;
                if (SCdataGridView1.Rows[i].Cells[8].Value.ToString() == "Male") //here the error occure because I put here i
                {
                    malecount = malecount + 1;
                    SClabel6.Text = malecount.ToString();
                }
            }

error is
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Answers (3)