473,226 Members | 1,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,226 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 2188
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'...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.