Reputation: 89
public Dictionary<string, TextBox> name_tbs = new Dictionary<string, TextBox>();
TextBox TextBoxbyName(string tb_name)
{
return name_tbs(tb_name);
}
Now it shows the error name_tbs dosent exist in current context .
Upvotes: 0
Views: 57
Reputation: 222722
You need to place it inside the [], because you are accessing using the key of a dictionary,
Dictionary<string, TextBox> name_tbs = new Dictionary<string, TextBox>();
TextBox TextBoxbyName(string tb_name)
{
return name_tbs[tb_name];
}
Upvotes: 1