Skip to main content

Interface member cannot have a definition

In This Article

CodeRush Classic shows the Interface member cannot have a definition code issue if an interface member has a definition.

#Fix

Remove the member definition.

#Purpose

Highlights the interface member declarations, which would cause the Interface members cannot have a definition compilation error.

#Example

public interface IMyInterface
{
    int GetTotalStringLength(string[] data)
    {
        int result = 0;
        foreach (string str in data)
        {
            result += str.Length;
        }
        return result;
    }
}

Fix:

public interface IMyInterface
{
    int GetTotalStringLength(string[] data);
}