Hi, Can enyone helpsme.Im new to C#.
i gt this error.
Embedded statement cannot be a declaration or labeled statement

My code is

foreach (Form form in Application.OpenForms){
                    if (form is productResults)
                      productResults pr =(productResults)form; 
}

PLZ...help me.

In line 2 you test if a form is productResults, so what do you mean by line 3?
If you get there IMHO you have a productResults form.

Edited 5 Years Ago by ddanbe: n/a

In line 2 you test if a form is productResults, so what do you mean by line 3?
If you get there IMHO you have a productResults form.

Oh! yes i understood. Thank you very much.

foreach (Form form in Application.OpenForms)
                {
                      productResults pr =(productResults)form; 
                    if ( pr is productResults)
                        pr.itemsGridView.DataSource = DS.Tables["product_Header"]; 
                }

But plz could you tell me what did you mean by IMHO?
I dont know whether it is silly to ask

Edited 5 Years Ago by __avd: Added [code] tags.

There are no silly questions, there are only dumb answers. IMHO is just a shortcut for saying In My Humble Opinion:)

Edited 5 Years Ago by ddanbe: n/a

>Embedded statement cannot be a declaration or labeled statement

Error says that embedded statement must be enclosed by {}.

foreach (Form form in Application.OpenForms)
{
  if (form is productResults)
    {
     productResults pr =(productResults)form; 
    }
}
This question has already been answered. Start a new discussion instead.