I have this namespace in Extensions.cs file:
namespace TextBoxExtensions
{
public static class TextBoxExtensionsClass
{
public static void ResetColor(this Label label)
{
label.ForeColor = new TextBox().ForeColor;
}
}
}
then:
using TextBoxExtensions;
//…
textbox.ResetColor();
when I try to access it in another file, I get the following error:
‘System.Windows.Forms.TextBox’ does not contain a definition for ‘ResetColor’ and the best extension method overload ‘TextBoxExtensions.TextBoxExtensionsClass.ResetColor(System.Windows.Forms.Label)’ has some invalid arguments
what type is
textbox? your extention is for aLabelobject. I am guessing that this is your problem…. that yourtextboxobject is not of type Label