-2
if (txt.Contains(textBox2.Text.Trim(), StringComparison.OrdinalIgnoreCase)) tabControl1.SelectedTab = tab;

I need it to be like a contains but i keep getting i can't do this i get no overload mesage

full script

        private void button4_Click(object sender, EventArgs e)
    {
        foreach (TabPage tab in tabControl1.TabPages)
        {
            var controls = tab.Controls;
            foreach (Control c in controls)
                if (c.GetType() == typeof(Label))
                {
                    //depends if you want to search by label text or name 
                    string txt = c.Text;
                    //string name = c.Name;
                    //MessageBox.Show(txt);
                   // if (txt.Contains (textBox2.Text.Trim())) tabControl1.SelectedTab = tab;
                    if (txt.Contains(textBox2.Text.Trim(), StringComparison.OrdinalIgnoreCase)) tabControl1.SelectedTab = tab;
                    //MessageBox.Show(textBox2.Text.Trim());
                }
        }
    }

thanks

1 Answers1

3

This is because of the version of .NET you're using.

Notice .NET 4.8 only has one overload: Contains(string)

However, .NET Core 3.1 has multiple overloads, including the one you're using: Contains (string, StringComparison)

There are ways around this, if you can't change frameworks. See this post for one example: Case insensitive 'Contains(string)'

Broots Waymb
  • 4,713
  • 3
  • 28
  • 51