Delegate parameter in interface method

The declaration of a delegate is a type itself, like declaring an interface or a class. Interfaces do not support nesting types in C# 7.3 and prior. To get your code working, you have to move the delegate declaration to the outer scope.

public delegate void DBOperationResult(string result); // a type itself

public interface IDatabaseItem
    int Id { get; }
    DateTime Date { get; }

    bool Delete(DBOperationResult foo);

With the introduction of ‘default interface implementations’ in C# 8.0 interfaces have been extended to permit the declaration of nested types (like your delegate).

See for more details.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top