I was reading a tutorial about making custom principal, and I’ve encountered the code:
public class BaseController : Controller
{
protected virtual new UserPrincipal User
{
get { return HttpContext.User as UserPrincipal; }
}
}
How exactly is “protected virtual new” working ?
Keyword “new” is what confuses me the most.
protectedmeans that it is visible only inside this class and classes derived from it.virtualmeans that it can be overriden in derived classes.newmeans that here you create new overriding hierarchy, i.e. you stop overriding the method defined in the base class and replace it with this method.More details can be found here