I have a list of words:
List<string> listofwords;
public void list()
{
listofwords = new List<string>();
listofwords.Add("tackle");
listofwords.Add("hinder");
listofwords.Add("mentor");
}
Each word contains multiple data in it:
public List<string> tackle;
public List<string> hinder;
public List<string> mentor;
public void A()
{
mentor = new List<string>();
mentor.Add("tern");
mentor.Add("tome");
mentor.Add("tone");
tackle = new List<string>();
tackle.Add("alce");
tackle.Add("cake");
tackle.Add("calk");
tackle.Add("cate");
tackle.Add("kale");
tackle.Add("lace");
hinder = new List<string>();
hinder.Add("deni");
hinder.Add("dine");
}
In the button click event, I want to check a list. The list's name is stored in a string variable val:
private void button1_Click(object sender, EventArgs e)
{
if (val.Contains(textBox1.Text )))
val.Remove(textBox1.Text);
}
How do I use val to check the list?
List.Containsshould work. Are you getting an error message?