The error is not in this passage; it is elsewhere. You must have defined an extension method within this class and you cannot define so because it is not static. As this excerpt makes it clear that the class cannot be static the problem is in the method set. Find it. It has a parameter with this
.
How class is partial
must have another part of it in another file. The part that gives problem may be in this other file.
If you really need this method as extension you should create a separate static class for it.
Another solution is to make this method normal and not extension by removing the modifier from the first parameter this
. Would look like this:
public static string TextNoFormatting(MaskedTextBox _mask) {
_mask.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
String retString = _mask.Text;
_mask.TextMaskFormat = MaskFormat.IncludePromptAndLiterals;
return retString;
}
I put in the Github for future reference.
The simple withdrawal of this
before the parameter _mask
solves the problem.
Like Sidenote this variable nomenclature is non-standard. There is no reason to use underscore.
Documentation on extension methods.
Only extension methods have constraints on how the class should be defined. Normal static methods can be in any class. The only question is whether he should be in the class, what he’ll do, access.
Place the code and error separately instead of the screen. This way it is difficult to find your question in searchers.
– Maniero
Besides this. Close, nowhere else has a parameter with this. ?
– Juliano de Souza
The ideal is to put only what is affecting you but if you don’t know where it is, it would be better. Note that the class is partial so there is another part of it somewhere.
– Maniero
It turns out that all the other classes are exactly the same as this, however, this error does not occur. I’m killing myself all day to be able to tidy up.
– Juliano de Souza