Skip to main content

Override member cannot be marked as virtual

In This Article

CodeRush Classic shows the Override member cannot be marked as virtual code issue if an override member is marked as virtual.

#Fix

Remove the virtual keyword from the member declaration.

#Purpose

Highlights the member declarations, which would cause the A member marked as override cannot be marked as new or virtual compilation error.

#Example

public virtual override void ProcessText(string text)
{
    base.ProcessText(text);
}

Fix:

public override void ProcessText(string text)
{
    base.ProcessText(text);
}