我通过继承RolesService来扩展一个新类.在RolesService中,我有一个静态方法,我想在我新派生的类中覆盖它.当我从派生对象进行调用时,它不使用重写的静态方法,它实际上调用基类方法.有任何想法吗?
public class RolesService : IRolesService
{
public static bool IsUserInRole(string username, string rolename)
{
return Roles.IsUserInRole(username, rolename);
}
}
public class MockRoleService : RolesService
{
public new static bool IsUserInRole(string username, string rolename)
{
return true;
}
}
Run Code Online (Sandbox Code Playgroud)