i am using custom role provider for that i made a CustomRoleProvider class and implemented some RoleProvider methods in it, like this
public class CustomRoleProvider: RoleProvider
{
public override void CreateRole(string roleName)
{
throw new NotImplementedException();
}
public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
{
throw new NotImplementedException();
}
}
All the methods are public.but it showing error that
Error 4-Inconsistent accessibility: base class
‘RoleProviderExample.RoleProvider’ is less accessible than class
‘RoleProviderExample.CustomRoleProvider’.
Where I am doing wrong ?
The base class
RoleProviderthat you are exposing viaCustomeRoleProvideris notpublic.If you declare
RoleProvideraspublicthe error will go away. You don’t have to giveRoleProviderapublicconstructor.Alternatively you could reduce the accesibility of
CustomRoleProviderto that ofRoleProvider. This may be the most appropriate answer, do you need to exposeCustomRoleProvideroutside the assembly?If
RoleProvideris an interface then, by convention, it is misnamed, you could rename it toIRoleProvider. In any case, it is still less accesible thenCustomRoleProvider.Make it public like this,
If you don’t specify the accesibility of an
interface,classorstruct,internalis implied.interfacemembers are alwayspublic.classandstructmembers areprivateunless specified.It is good practice to specify, except in the case of interface members which are always
public.Your implementation could look like this, the
overridekeyword should not be used for interface implementations, unless they are overriding an overridable base class implementation.if you want to explicity implement the interface,