473,728 Members | 2,103 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about attributes


How can I create attribute and specify that it can be applied only to the
non private fields or properties?

Thank you
Feb 14 '06 #1
2 968
David Dvali <da*********@ho tmail.com> wrote:
How can I create attribute and specify that it can be applied only to the
non private fields or properties?

You can't, I'm afraid. You can specify that it can only be applied to
properties and fields, but you can't force them to be non-private ones.

However, it wouldn't be hard to write a verification tool which loaded
an assembly, scanned all the types for the attribute being applied, and
checked the accessibility of the fields/properties which had the

Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 14 '06 #2
You can use the AttributeUsage attribute to indicate that the custom
attribute is applicable only to fields and properties, although I'm not sure
if there's a way to specify which access modifiers are valid.

Tim Wilson
..NET Compact Framework MVP

"David Dvali" <da*********@ho tmail.com> wrote in message
news:e$******** *****@TK2MSFTNG P10.phx.gbl...

How can I create attribute and specify that it can be applied only to the
non private fields or properties?

Thank you

Feb 14 '06 #3

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

Similar topics

by: SB | last post by:
I have an assignment where we are supposed to mimic a scheduler routine of an OS. We are supposed to schedule some processes, an each process has the following attributes... - process id - execution time - memory size All the above are int values. We have to prompt the user to input the number of processes and then store those processes (with the 3 attributes) in a vector. So the size of the vector is unknown until a user inputs a...
by: Tony Johansson | last post by:
Hello! I'm reading a book about C++ and there is something that I don't understand so I ask you. I have marked the section from the book that is of intertest by tagging it with BOOK START HERE and ending with BOOK ENDING HERE. All that text between is just a copy from the book. My question come after the text section. The book says
by: Tim Mavers | last post by:
I have a series of database objects that represent things such as people, accounts, etc. I have a set of options (boolean) that I need to add to these objects. Normally I would just create a bit field for each one and be done with it. The challenge however is that there could be hundreds of these options (maybe 300) and a user decides which of these options (actually attributes) that should apply to these db objects. For example, a...
by: Developer | last post by:
Hello, I'm experimenting with and XmlTextReader sample, and don't understand how the attributes are being processed. Here's the input: <xsd:element name="AA" type="BB" substitutionGroup="CC"/> The code: while (reader->Read()) {
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read somewhere that each folder under the "web site" is compiled in separate assembly. I however, did not find that the "web site" creation in vs.net 2005 created any AssemblyInfo.cs file.
by: Marcel Hug | last post by:
Hello NG ! I have a tricky question about dataSet and dataTable. In my app I have 2 databases. In the first (called A1) database are the whole datas but I'm interesting in one table tbl1 (with 20 attributes). To communicate with the DB A1 I have a lib, which gives me a dataset of this table tbl1 (with all attributes). This dataset i would like to give the lib for my second DB A2. In this DB A2 is a table tbl2 which has just some of the...
by: Doru Roman | last post by:
Hello, I got a test and some of the questions were: A collection a files, which is the basic unit of .NET programming, is called: 1. package 2. assembly 3. library 4. copybook
by: Ryan | last post by:
I'm in the process of learning more about building my ASP.NET website to use my SQL datastore and am a bit confused about how ADO.NET works with ASP.NET. This Microsoft article implies that using ADO.NET with ASP.NET applications is the way of the past because newer controls allow you to do all your data binding declaratively. http://msdn2.microsoft.com/en-us/library/ms178359(d=ide).aspx However, I haven't been able to get my application...
by: Alan Isaac | last post by:
I have a class whose instances should only receive attribute assignments for attributes that were created at inititialization. If slots are not appropriate, what is the Pythonic design for this? Thanks, Alan Isaac
by: RobG | last post by:
I have always accessed attributes such as disabled using the DOM element property, however I was wondering about implementing a more generic function to get the values of attributes - which of course leads to the DOM Element Interface's getAttribute method: <URL: http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-666EE0F9 > The DOM 2 Core specification says that getAttribute should return the value of an attribute as a string, however...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.