473,329 Members | 1,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,329 software developers and data experts.

Forcing attributes

Question from experienced programmer, but C# newbie:

Can I force the application of an attribute -- to be detected at
compile time?

I've got some J. Random Interface:

interface IRandomInterface {

void Method1();
void Method2();

}

Is there any way that I can force an object that implements
this interface to be decorated with a custom attribute of a
specific type. Not just the class, but on the method level
too -- can I force the implementor of the interface to decorate
both the class and the methods with an attribute of a particular
(custom) type -- and have the compliler catch it if a required
attribute is missing?

Thanks in advance.


Nov 16 '05 #1
1 1029
Is there any way that I can force an object that implements
this interface to be decorated with a custom attribute of a
specific type. Not just the class, but on the method level
too -- can I force the implementor of the interface to decorate
both the class and the methods with an attribute of a particular
(custom) type -- and have the compliler catch it if a required
attribute is missing?

No you can't.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2

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

Similar topics

50
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...
40
by: Neo The One | last post by:
I think C# is forcing us to write more code by enforcing a rule that can be summarized as 'A local variable must be assgined *explicitly* before reading its value.' If you are interested in what...
6
by: G Dean Blake | last post by:
in my aspx app I am writing a stream that works fine but it replaces what is in the client browser window. The code is as follows: .. .. HttpContext.Current.Response.ClearHeaders()...
6
by: SkeanDu | last post by:
Ok, here is my problem. I have an aspx page that displays a databound datagrid and in one of the datagrid column headers I have an image that when clicked opens up a modal web dialog (another...
0
by: slakr | last post by:
I am trying to override the attributes of hyperlinks so that they display like adjacent text when printed. I used the following CSS: <style type="text/css"> @media print { A { color :...
2
by: Scott | last post by:
Are there any div attributes that could force a div element to stay in the background? I have a .vbs calendar class that opens a small calendar. Unfortunately, sometimes it opens above a form...
9
by: Joel Byrd | last post by:
I've got a div whose width is specified as a percentage so that if you shrink the browser window, the div shrinks, and the text inside the div wraps around to accommadate this. The problem is:...
13
by: Lad | last post by:
If I have a list Mylist= I can print it for i in Mylist: print i and results is 1
4
by: Michael Malinowski | last post by:
Hey All, Apologies if this is a stupidly obvious or simple question. If I have a class with a series of attributes, is there a way to run a function definition in the class whenever a specific...
4
by: ATS16805 | last post by:
Hi. I wonder if it's possible to "force" a browser to "switch to SSR mode" for any given document. Specifically, I'm looking for a solution, not to a User Agent issue (i think), but a coding idea;...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.