C# 修饰符“abstract”;对该商品无效

发布于 2024-10-30 05:22:30 字数 586 浏览 1 评论 0原文

我正在尝试构建另一个人的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

流云如水 2024-11-06 05:22:30

只需删除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.

美男兮 2024-11-06 05:22:30

请参阅此 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

娜些时光,永不杰束 2024-11-06 05:22:30

接口不允许包含诸如 abstractvirtualpublicprotectedprivate 等修饰符代码>, ...
解决方案:
只需将其删除即可。

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

清醇 2024-11-06 05:22:30

在 .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.

别在捏我脸啦 2024-11-06 05:22:30

确实是无效的。删除abstract关键字并重新编译。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文