Valerie Meunier

Valerie Meunier

  • NA
  • 693
  • 82.4k

System.NullReferenceException

Jan 2 2022 10:18 AM

Hi

i get the System.NullReferenceException error with this code at line txt[i].Text = i.ToString();

Thanks

 private void button1_Click(object sender, EventArgs e)
        {
            TextBox[] txt = new TextBox[5];
            for (int i = 0; i < 5; i++)
            {
                txt[i].Text = i.ToString();
            }
        }


Answers (1)