Hedge
Hedge

Reputation: 16768

C# The modifier 'abstract' is not valid for this item

I'm trying to build a C# project of another guy. In a lot of interfaces I get the error:

The modifier 'abstract' is not valid for this item

In the following Interface:

namespace Services.Email
{
    using System;
    using System.Collections;
    using.System.Collections.Generic;
    using System.Runtime.CompilerServices;

    public interface IEmailService
    {
        abstract event EventHandler<SendCompletedEventArgs> SendSummaryCompleted;

        void SendNewsItem(DocumentNewsItem newsItem, string email);
        void SendSummaryAsync(Session session, Advisor advisor);
    }
}

Upvotes: 3

Views: 6696

Answers (5)

Priyank
Priyank

Reputation: 10623

Refer to this MSDN article: http://msdn.microsoft.com/en-us/library/aa664580%28v=vs.71%29.aspx

All interface members implicitly have public access. It is a compile-time error for interface member declarations to include any modifiers. In particular, interfaces members cannot be declared with the modifiers abstract, public, protected, internal, private, virtual, override, or static.

Solution: Remove "abstract" modifier

Upvotes: 3

Mat&#237;as Fidemraizer
Mat&#237;as Fidemraizer

Reputation: 64943

In .NET and C#, member modifiers in interfaces aren't supported.

If you want such thing you'd be better switching them to abstract classes, but IMHO this isn't a good way of developing software (refactoring code without thinking what's the actual requirement).

Easy solution: just remove any modifier, leave type, identifier and parameters of any kind of interface member.

Upvotes: 1

RQDQ
RQDQ

Reputation: 15579

It is indeed not valid. Remove the abstract keyword and re-compile.

Upvotes: 0

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174397

Interfaces are not allowed to contain modifiers like abstract, virtual, public, protected, private, ...
Solution:
Just remove it.

Upvotes: 1

Jamie Treworgy
Jamie Treworgy

Reputation: 24344

Just remove abstract, it's not applicable to interfaces. Everything in an interface is already essentially "abstract". An abstract class is actually in many ways the same thing as a class with a required interface that is not implemented.

Upvotes: 15

Related Questions