Reputation: 16768
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
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
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
Reputation: 174397
Interfaces are not allowed to contain modifiers like abstract
, virtual
, public
, protected
, private
, ...
Solution:
Just remove it.
Upvotes: 1
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