0
 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 .

1
  • Mmmm... use square brackets? name_tbs[tb_name] Commented Dec 12, 2016 at 6:22

1 Answer 1

1

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];
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.