I am trying to access a Textbox in my form by casting a string equivalent to Textbox name in my form but i get error stating "Object reference not set to an instance of object"
private void writetotexboxarray()
{
// for (int i = 0; i < 9; i++)
//{
//for (int j = 0; j < 4; j++)
//{
textboxname= "Textbox" + 0 + 0;
MessageBox.Show(textboxname);
TextBox t = new TextBox();
t = (TextBox)(this.Controls[textboxname]);
//readintakedata[0,0].Text = t.Text;
try
{
string value = t.Text;
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
// }
// }
}