I created the following constructors for my class:
public class AccountService : IAccountService
{
public AccountService(Meta meta)
{
Initialize(meta.DataSourceID);
}
public AccountService(string dataSourceID)
{
Initialize(dataSourceID);
}
However when I call the class:
_accountService = new AccountService(vm.Meta);
I get the following message:
Error 16 The best overloaded method match for ‘AccountService.AccountService(string)’ has some invalid
arguments
Is there something basic that I am missing here? When coding intellisense gives me the two options and
there’s no syntax error when I use intellisense to select vm.Meta? Do I need to declare constructors in the
interface?
No. You cannot decalre constructors in an interface. Interfaces represent a declaration of your type’s public api; they do not in any way specify how implementing classes are created
The code you have is correct, conceptually at least; the problem is likely that
vm.Metais not of typeMeta, or a type that inherits fromMeta.