Skip to main content

Abstract member cannot be marked as virtual

In This Article

CodeRush Classic shows the Abstract member cannot be marked as virtual code issue if a member declaration contains both abstract and virtual keywords.

#Fix

Remove the virtual keyword from the member declaration statement.

#Purpose

Highlights the abstract member declarations, which would cause the The abstract method ‘Method name’ cannot be virtual compilation error.

#Example

public abstract class MyShape
{
    public virtual abstract double GetArea();
}

Fix:

public abstract class MyShape
{
    public abstract double GetArea();
}