473,406 Members | 2,710 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,406 software developers and data experts.

C# Attributes

A.M
Hi,

I am trying to grasp a better underestanding of C# Attributes . I don't see
them as a very usefull capability.

Could anyone refer me to resources show me best practices and how can I
improve my code using attributes?

Thanks,
Allan
Nov 16 '05 #1
6 2196
Attribute is a very powerful tool. you may take a look at XML Serialization
things, which use attribute quite a lot.

"A.M" <IH*******@sapm123.com> дÈëÓʼþ
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

I am trying to grasp a better underestanding of C# Attributes . I don't see them as a very usefull capability.

Could anyone refer me to resources show me best practices and how can I
improve my code using attributes?

Thanks,
Allan

Nov 16 '05 #2
A.M wrote:
Hi,

I am trying to grasp a better underestanding of C# Attributes . I don't see
them as a very usefull capability.

Could anyone refer me to resources show me best practices and how can I
improve my code using attributes?

Thanks,
Allan


I can recommend You do read in .NET docs:

"Design-Time Attributes for Components"
"Attributes and Design-Time Support"

Cheers

Marcin
Nov 16 '05 #3
Please check:
http://www.codeproject.com/csharp/dotnetattributes.asp

Fakher Halim

"A.M" <IH*******@sapm123.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

I am trying to grasp a better underestanding of C# Attributes . I don't see them as a very usefull capability.

Could anyone refer me to resources show me best practices and how can I
improve my code using attributes?

Thanks,
Allan

Nov 16 '05 #4
Allan,

When I first started doing C#, I didn't really see the value of attributes
right off the bat either. Once you start using them though, you may begin to
wonder how you ever managed without them.

There are so many uses for attributes, it's hard to even begin listing them,
but here are a few quick ones:

1: Generic access to class data - I have a project on SourceForge
(http://dotnetdallib.sourceforge.net) that is a data access library. Using
attributes that specify the relationship of data classes to the underlying
database, I'm able to generate dynamic SQL statements to populate data
objects from the database or to write data objects to the database.

2: Similar to 1, attributes can be used to modify the behavior of
serialization of classes using the binary or xml serialization. And there
are actually quite a few other places in .NET where attributes are used to
modify how data is handled.

3: They're used extensively in custom controls to define how the controls
interact with the property grid and other aspects of the IDE.

4: They're can be used as a form of inline documentation (such as the
Obsolete attribute)

If you check the documentation:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2004JAN.1033/cpref/html/frlrfsystemattribu
teclasshierarchy.htm

You'll see that there are a great number of classes derived from
System.Attribute. That alone should hint at how useful they are.

Pete

"A.M" <IH*******@sapm123.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

I am trying to grasp a better underestanding of C# Attributes . I don't see them as a very usefull capability.

Could anyone refer me to resources show me best practices and how can I
improve my code using attributes?

Thanks,
Allan

Nov 16 '05 #5
Hi Allan,

I think the community has provided much information on your issue. Do you
still have any concern on this issue?

Please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #6
A.M

I am fine now. Thank you Jeffrey. This newsgroup is amazing!!


""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:6j**************@cpmsftngxa10.phx.gbl...
Hi Allan,

I think the community has provided much information on your issue. Do you
still have any concern on this issue?

Please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #7

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...
1
by: John L. Clark | last post by:
I am curious as to the rationale, and effect, of having default namespaces not applying (directly) to attributes (see http://www.w3.org/TR/REC-xml-names/#defaulting). Given an attribute without a...
9
by: Soren Kuula | last post by:
Hi, I just can't find namespaces of attributes stated clearly enough in the XML namespace spec. But .. I hear rumors that attributes, unless qualified otherwise, default to the namespace of the...
7
by: Info 3000 | last post by:
Hello, I'm beginner in XML. I have just a little question : I understand that I can write : <Book> <Title> A nice day </Title> <Author> James Nicepen </Author> </Book>
7
by: John R. | last post by:
How do you set the following file attributes: Compressed Encrypted Normal ReparsePoint SparsePoint You CAN'T set these using FileInfo.Attributes or File.SetAttributes. It doesn't work for...
7
by: localhost | last post by:
What is the best and/or fastest way to enumerate attributes of an HTML control? In my page template, I have: <body id="myBody" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0"...
3
by: Janaka | last post by:
I've seen and used some samples where you can set the onclick attrubute to a Button control to get it to do some javascript a la : btnUse.Attributes = "DoSomeJS()"; However when i try and get...
2
by: prabhupr | last post by:
Hi Folks I was reading this article (http://www.dotnetbips.com/articles/displayarticle.aspx?id=32) on "Custom Attribute", written by Bipin. The only thing I did not understand in this article...
2
by: james_027 | last post by:
hi everyone, I am now in chapter 5 of Dive Into Python and I have some question about it. From what I understand in the book is you define class attributes & data attributes like this in python...
2
by: cloftis | last post by:
Using VS2003, VB and MSHTML, Using an HTMLSpanElement I want to enumerate the attributes of a SPAN tag. 1 'For testing sake 2 Dim strMarkup as String = "<span attr1='somevalue'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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
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
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
jinu1996
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...
0
tracyyun
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...
0
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,...

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.