Doubt about ContainsIgnoreCase in a textBox

0

The problem is in the following description:

  

Error CS1061

     

"string" does not contain a setting for "ContainsIgnoreCase" and has not been   possible to find any "ContainsIgnoreCase" extension method that   accept a first argument of type "string" (there is a usage directive   or missing assembly reference?)

I created an extension at first in a public static, but it did not work. What else can I do?

Error occurs in [Step 2.1]

namespace MyMethod 
{
    public static class MyExtensions 
    {
        public static bool ContainsIgnoreCase(this string source, string search)
        {

           return source.IndexOf(search, StringComparison.CurrentCultureIgnoreCase) >= 0;

        }   
    }    
}

Use

private void txtBuscarJogo_TextChanged(object sender, EventArgs 
{
    var controles = _todosBotoes.Where(btnArcheAge => (btnArcheAge.Tag as String ??    btnArcheAge.Text).ContainsIgnoreCase(txtBuscarJogo.Text)).ToArray();
    //Passo 2.2
    mainPanel.Controls.Clear();
    //Passo 2.3
    mainPanel.Controls.AddRange(controles);
}
    
asked by anonymous 08.05.2017 / 22:11

1 answer

0

It only needs to include the namespace in the Form class. In fact, the namespace name is not good, try to put something more descriptive like MyExtensionsMethods .

// Outros using
using MyMethod;

namespace SeuNamespace
{
    public partial class Form1 { }
}
    
08.05.2017 / 22:18