The requested page is not available for the requested platform. You are viewing the content for Default platform.

Interface events cannot have add or remove accessors

CodeRush Classic shows the Interface events cannot have add or remove accessors code issue if an event declaration within an interface includes add or remove accessors.

Fix

Remove the redundant accessors from the event declaration within an interface.

Purpose

Highlights the event declarations within interfaces, which would cause the An event in an interface cannot have add or remove accessors compilation error.

Example

public interface IMyInterface
{
    string StringData{get;set;}
    string ProcessData();
    event EventHandler DataProcessed{add;remove;}
}

Fix:

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