什么是接口上使用的属性? [英] What's the use of attributes on an interface?

查看:101
本文介绍了什么是接口上使用的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ReSharper的,我提取现有类的接口。这个类有一些属性上几件设置,并且ReSharper的也把这些在接口的成员。

Using Resharper, I extracted an interface of an existing class. This class has some attributes set on a few members, and Resharper also put these on the interface members.

我可以取消接口这些属性? 在接口上的属性实现接口权当是不能继承?

Can I delete these attributes from the interface? Attributes on an interface aren't inherited when implementing an interface right?

推荐答案

他们不习惯的实现类 - 但仍然可能是至关重要的。例如,WCF通过界面上的属性定义了服务合同和操作 - 合同。

They aren't used by the implementing class - but still might be critical. For example, WCF defines service-contracts and operation-contracts by the attributes on the interface.

。如果他们不使用的你的情况的,然后将其删除。否则,让他们独自;-p

If they aren't of use in your case, then delete them. Otherwise, leave them alone ;-p

这篇关于什么是接口上使用的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆