468,514 Members | 1,627 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,514 developers. It's quick & easy.

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 2042
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

50 posts views Thread by Dan Perl | last post: by
1 post views Thread by John L. Clark | last post: by
9 posts views Thread by Soren Kuula | last post: by
7 posts views Thread by Info 3000 | last post: by
7 posts views Thread by localhost | last post: by
3 posts views Thread by Janaka | last post: by
2 posts views Thread by prabhupr | last post: by
2 posts views Thread by james_027 | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.