Doubt about Containsignorecase in a textbox

Asked

Viewed 94 times

0

The problem is in the following description :

CS1061 error

"string" does not contain a definition for "Containsignorecase" and was not can find no method of extension "Containsignorecase" that accept a first "string" argument (there is a usage directive or missing Assembly reference?)

I created an Extension there at the beginning in a public Static, but it didn’t help.. What else can I do?

Error happens 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);
}
  • Do not use images, paste the error message text.

  • 1

    Also take care of code formatting, the harder it is to read, the fewer people willing to help.

1 answer

0

All that remains is to include the namespace in the class of Form. In fact, the name of namespace is not good, try to put something more descriptive, as MyExtensionsMethods.

// Outros using
using MyMethod;

namespace SeuNamespace
{
    public partial class Form1 { }
}
  • Answer, I had no error when it includes mymethod, I gave start to test, and my whole program gave error ! : O, I don’t know if I ran into a key and erased a line, but my form doesn’t even show up anymore. ERROR : The Form1 class can be created, but it is not the first class of the file. Visual Studio requires designers to use the first class file. Move the class code so that it is the first class of the file, and try to load the designer again.

  • I really wanted to understand where you wanted to go until I agree that the name could be better (could) up because this namespace should have two names separated by . being used a lot like this. ends up being also opinionated ...

  • Yeah, I ended up writing superficially first, but dps gave an improved.

  • @Dáriosabaini I have no idea what you’ve done. Try a Ctrl+z

  • http://prntscr.com/f5lukh it seems that I erased something, or put something in the wrong order... but I have no idea what it is

  • @Dáriosabaini has a lot going on in this project?

  • @Dáriosabaini The using needs to be before the class declaration

  • I asked for help from a friend he said that it is not usually good to have 2 namespace in a project. It is probably where I’m stuck. I put using Mymethod in the beginning but it still didn’t work. I’ll keep trying

  • 1

    Ask your friend to base what he said. Information without foundation is opinion or achism and these two are worth nothing =D

  • @Dáriosabaini tells his friend that he is very much mistaken, what happened to you is another problem, imagine you think so adding a new package on your system, which has a namespace different, invalid information ...

  • 1

    I got you guys !! IT WAS SO SIMPLE... just put that namespace there at the end of the code... because the form has to come first of all. Thank you very much jbueno and compania :)

  • @Dáriosabaini Something is wrong. The using does not need to be at the end of the code. Other than that, the question is solved? You need something else?

Show 7 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.