Thinking the following code:
This is BaseService.
the content of the cs
public virtual async TaskAdd (TViewModel viewModel, TEntity entity)
This is sysUserInfoService.
the content of the cs
public class SysUserInfoServices: BaseServices, ISysUserInfoServices
Including UserViewModel for
public class UserViewModel: IUserViewModel
{
Public UserViewModel ()
{
}
}
And has the following UserCreateDto
public class UserCreateDto: IUserViewModel
I set rewrite BaseService. The Add method of cs, but I failed...
public override async TaskAdd (UserCreateDto UserCreateDto, sysUserInfo entity)
{
return 0;
}
Tip can't find the suitable method to override a...
Could you tell me how to handle this? Thank you.
CodePudding user response:
The static void Main (string [] args){
D D=new D ();
Da Fan (new B1 ());
Da Fan (new B2 ());
Da Fan (new C ());
}
The class A
{
Public virtual int AFan (T T)
{
return 0;
}
}
B1: class C
{
}
The class B2: C
{
}
Class C
{
}
Class D: A
{
Public override int AFan (C of C)
{
return 1;
}
Public override int AFan (B1 B1)//not to find the right way to rewrite
{
Return 2;
}
Public override int AFan (B2 B2)//not to find the right way to rewrite
{
Return 3;
}
}
You can put the BaseServices
Public override async Task
Rewrite UserCreateDto IUserViewModel instead,
CodePudding user response:
Generics are BaseService incoming?public interface IUserViewModel
{}
Public class UserViewModel: IUserViewModel
{}
Public class UserCreateDto: IUserViewModel
{}
Public interface ISysUserInfoServices
{}
Public class SysUserInfo
{}
Public class BaseService
{
Public virtual async TaskAdd (TViewModel viewModel, TEntity entity)
{
return 0;
}
}
Public class SysUserInfoServices: BaseService, ISysUserInfoServices
{
Public override TaskAdd (UserViewModel viewModel, SysUserInfo entity)
{
Return the base. The Add (viewModel, entity);
}
}
CodePudding user response:
Moderator: hello,BaseService incoming is...
public class SysUserInfoServices: BaseServices, ISysUserInfoServices