473,498 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Attributes on interface property not enforced on concrete class

I added a property to an interface like this:
<code>
public interface ISimpleAddress
{
[Bindable(BindableSupport.Yes)]
[EditorBrowsable(EditorBrowsableState.Always)]
string CarrierFax{ get; set; }
}
</code>

I was disappointed to see that when I implemented the interface:
1) Visual Studio Refactoring-Auto-Implement tool didn't add the attributes
2) If I omitted the attributes from the concrete class the compiler didn't
complain.

Why do interfaces allow attributes if they won't be enforced?

Anyone know?
Jan 20 '08 #1
1 1683
On Jan 19, 11:07 pm, "Steve K." <no...@nowhere.comwrote:
I added a property to an interface like this:
<code>
public interface ISimpleAddress
{
[Bindable(BindableSupport.Yes)]
[EditorBrowsable(EditorBrowsableState.Always)]
string CarrierFax{ get; set; }}

</code>

I was disappointed to see that when I implemented the interface:
1) Visual Studio Refactoring-Auto-Implement tool didn't add the attributes
2) If I omitted the attributes from the concrete class the compiler didn't
complain.

Why do interfaces allow attributes if they won't be enforced?

Anyone know?
Attributes on an interface member aren't part of the interface
contract, they're modifiers for the member as *part of that
interface*. For example, you might use an attribute to affect whether
CarrierFax is displayed in the IntelliSense list for an ISimpleAddress
variable.

Jesse
Jan 20 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

50
6283
by: Dan Perl | last post by:
There is something with initializing mutable class attributes that I am struggling with. I'll use an example to explain: class Father: attr1=None # this is OK attr2= # this is wrong...
5
454
by: Doug Holland | last post by:
Often you see code where an empty interface is used to indicate something about the class that realizes it. In the .NET world this can be done with custom attributes too, so which is better: ...
3
3353
by: Davide M3xican Coppola | last post by:
Hi, I would realize an interface (interface) for a pair of concrete classes (concrete & concrete2), but I have a problem because I have to access to a third class (element) and if I try to declare...
1
8446
by: Microsoft | last post by:
Hello there, I have following situation , how can I solve this puzzle in C#. I have interface called IVendor with some custom attributes applied to it interface IVendor {
7
1892
by: tron.thomas | last post by:
Please consider the following code: class Abstract { public: virtual ~Abstract() {} virtual void Method() = 0; }; class Concrete : public virtual Abstract
5
1335
by: Eric | last post by:
Hi, I am kind of new to OO and I have the following problem : I have a class containing a huge list of functions for accessing an SQL database. Public Class Transaction #region "Client"...
0
1555
by: mvanroshum | last post by:
Hi, I have the following problem: The DataSource of a DataGrid can be set to an IList. The DataGrid nicely lists the objects in the IList, showing all the public properties of the objects as...
5
3659
by: florin | last post by:
hi Is there a "simple" way to add attributes to a class/property at runtime? What I try to do is set the default editor for a class/property at runtime (I know I can set this very easy by...
26
1878
by: tjhnson | last post by:
Hi, With properties, attributes and methods seem very similar. I was wondering what techniques people use to give clues to end users as to which 'things' are methods and which are attributes. ...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4908
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.