I have an Interface [a] and a Implementer class [b]. [b] have its own methods apart of the implemented ones.
//-----------
public interface a
{
void functionA();
}
//-----------
public class b:a
{
void functionA(){}
void functionB(){}
}
//------------
In project X inside the solution. When I code: [project is a class library]
a test = new b();
test.functionB(); //It Works
In another project with a references to the library [Console application]
a test = new b();
test.functionB(); //Error CS1061 --> a doesn't have a method called function b
Sorry but names are in spanish. Interface: pastebin.com/Unm5Adkd, Implementer: pastebin.com/wmikck9H, Program: Console app: pastebin.com/Yus91hQL… Thanks everyone for your help. 😛
I assume that you are asking why you are getting the CS1061 error.
It’s simple. In your console application even though you instantiate an object of type ‘b’ (“new b()”) you appear to assign it to a variable referring to something that is an ‘a’. The interface ‘a’ according to your sample does indeed not contain a method called ‘functionB()’.
You have two options in this case.
Option one is adding method ‘functionB()’ to the interface definition as well:
Option two is making sure that variable ‘a’ in your console application is of type ‘b’:
On a side note I would suggest to stick with generally accepted naming guidelines, e.g. starting with uppercase letters for names of classes and methods.