Valerie Meunier

Valerie Meunier

  • NA
  • 693
  • 84.4k

embedded statement cannot be a declaration ..."

Jan 16 2022 3:36 PM

Hi

I have 6 labels on the form (from toolbox). Now i'm trying to catch them., but this code gives "embedded statement cannot be a declaration ..."

Thanks.

  private void button1_Click(object sender, EventArgs e)
        {
            for (int k = 1; k <= 6; k++)
                Label lbl = (Label)Controls["label" + k.ToString()]; // error
        }


Answers (3)