Mihir
Mihir

Reputation: 89

Name dosent exist in Current Context Error

 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

Answers (1)

Sajeetharan
Sajeetharan

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

Related Questions