Skip to main content

Abstract member cannot be declared in nonabstract class

In This Article

CodeRush Classic shows the Abstract member cannot be declared in nonabstract class code issue if a non-abstract class contains an abstract member.

#Fix

Add the abstract keyword to the class declaration statement.

#Purpose

Highlights the abstract member declarations, which would cause the ‘Member name’ is abstract but it is contained in non-abstract class compilation error.

#Example

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

Fix:

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