C# Foreach Loop - Continue Issue

Posted by Goober on Stack Overflow See other posts from Stack Overflow or by Goober
Published on 2009-05-02T16:28:46Z Indexed on 2010/04/21 7:13 UTC
Read the original article Hit count: 378

Filed under:
|
|
|

I have a problem with a continue statement in my C# Foreach loop.

I want it to check if there is a blank cell in the datagridview, and if so, then skip printing the value out and carry on to check the next cell.

Help appreciated greatly.

Here is the code:

foreach (DataGridViewRow row in this.dataGridView1.Rows)
{                            
    foreach (DataGridViewCell cell in row.Cells)
    {
        if (cell.Size.IsEmpty)
        {
            continue;
        }
        MessageBox.Show(cell.Value.ToString());
    }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about foreach