The requested page is not available for the requested platform. You are viewing the content for Default platform.

Override member cannot change access rights

CodeRush Classic shows the Override member cannot change access rights code issue if an override member access modifier does not match the overridden member access modifier.

Fix

Specify the same access modifier for the override and base members.

Purpose

Highlights the member declarations, which would cause the 'Member name': cannot change access modifiers when overriding inherited member compilation error.

Example

public class MyBase
{
    public virtual void ProcessText(string text)
    {
        Console.WriteLine(text);
    }
}
public class MyClass: MyBase
{
    internal override void ProcessText(string text)
    {
        base.ProcessText(text);
    }
}

Fix:

public class MyBase
{
    public virtual void ProcessText(string text)
    {
        Console.WriteLine(text);
    }
}
public class MyClass: MyBase
{
    public override void ProcessText(string text)
    {
        base.ProcessText(text);
    }
}