C# 修饰符“abstract”;对该商品无效
我正在尝试构建另一个人的 C# 项目。 在很多接口中我收到错误:
The modifier 'abstract' is not valid for this item
在以下接口中:
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);
}
}
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);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
只需删除
abstract
,它不适用于接口。界面中的所有内容本质上已经是“抽象的”。抽象类实际上在很多方面与具有未实现的所需接口的类相同。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.请参阅此 MSDN 文章: http://msdn .microsoft.com/en-us/library/aa664580%28v=vs.71%29.aspx
所有接口成员都隐式具有公共访问权限。接口成员声明包含任何修饰符都是编译时错误。特别是,接口成员不能使用修饰符abstract、public、protected、internal、private、virtual、override或static来声明。
解决方案:删除“abstract”修饰符
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
接口不允许包含诸如
abstract
、virtual
、public
、protected
、private
等修饰符代码>, ...解决方案:
只需将其删除即可。
Interfaces are not allowed to contain modifiers like
abstract
,virtual
,public
,protected
,private
, ...Solution:
Just remove it.
在 .NET 和 C# 中,不支持接口中的成员修饰符。
如果您想要这样的东西,最好将它们切换为抽象类,但恕我直言,这不是开发软件的好方法(重构代码而不考虑实际需求是什么)。
简单的解决方案:只需删除任何修饰符,保留任何类型接口成员的类型、标识符和参数。
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.
确实是无效的。删除abstract关键字并重新编译。
It is indeed not valid. Remove the abstract keyword and re-compile.