views:

347

answers:

2

Duplicate of can a c class inherit attributes from its interface

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?

A: 

They aren't inherited but depending on the attribute you can still do interesting things. For instance if you are using the validation block from the entlib, you can use the attributes on the interface to do validation on all classes derived from it without needing to retype the validation rules on the classes.

Robert MacLean
+5  A: 

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.

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

Marc Gravell