Skip to main content

Interface cannot contain constructors

In This Article

CodeRush Classic shows the Interface cannot contain constructors code issue if a constructor is declared within an interface.

#Fix

Remove the constructor declaration from the interface.

#Purpose

Highlights the interface declarations, which would cause the Interfaces cannot contain constructors compilation error.

#Example

public interface IMyInterface
{IMyInterface();
    string StringData{get;set;}
    string ProcessData();
}

Fix:

public interface IMyInterface
{
    string StringData{get;set;}
    string ProcessData();
}