I have an Interface like this:
namespace QuickRoutes.Model.Utilities
{
public interface IRoutesManager
{
bool ImportRoute(Stream inputStream, string fileName);
List<Route> GetAllRoutes();
List<Route> GetAllRoutesForDate(DateTime from, DateTime to);
void DeleteRoute(string routeName);
void DeleteAllRoutes();
}
}
and I want to access to i.e ImportRoute function from my Form but I cant access to this Function and an error occured like this:
cannot create an instance of the abstract class or interface
How can I access to these functions?
You need to have an implementation of the interface which defines the actual behaviour. The interface itself only declares the members – as you can see, there’s no code there to say what to do.
Your
Formcan either create an instance of some implementation, or be given it – quite possibly only as anIRoutesManager, so that the form itself doesn’t need to care about which implementation it’s using.