473,396 Members | 1,775 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,396 software developers and data experts.

A question about attribute

Hello!

I have two questions about attribute.
If you want to associate an attribute with a class you put the attribute
just before the class definition.
Like this
[myAttribute()]
public class myClass
{//some code here }

I know that it's possible to associate an attribute with an assembly.
But if you want to associate an attribute with an assembly where do you put
the attribute then?
My second question about attribute is it the same if I write the attribute
like this
[myAttribute()]
or
like this
[myAttribute]

//Tony



Aug 7 '06 #1
3 1118
Tony Johansson <jo*****************@telia.comwrote:
If you want to associate an attribute with a class you put the attribute
just before the class definition.
Like this
[myAttribute()]
public class myClass
{//some code here }

I know that it's possible to associate an attribute with an assembly.
But if you want to associate an attribute with an assembly where do you put
the attribute then?
It doesn't matter - you just need to use "assembly:" appropriately. See
the autogenerated AssemblyInfo.cs file for examples.
My second question about attribute is it the same if I write the attribute
like this
[myAttribute()]
or
like this
[myAttribute]
Yes. The brackets are really only needed when you're specifying
arguments/properties.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 7 '06 #2
Yes. The brackets are really only needed when you're specifying
arguments/properties.
and so is the attribute part of the term for C#
ex. [myattribute] can be written as [my]
--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
Tony Johansson <jo*****************@telia.comwrote:
>If you want to associate an attribute with a class you put the attribute
just before the class definition.
Like this
[myAttribute()]
public class myClass
{//some code here }

I know that it's possible to associate an attribute with an assembly.
But if you want to associate an attribute with an assembly where do you
put
the attribute then?

It doesn't matter - you just need to use "assembly:" appropriately. See
the autogenerated AssemblyInfo.cs file for examples.
>My second question about attribute is it the same if I write the
attribute
like this
[myAttribute()]
or
like this
[myAttribute]

Yes. The brackets are really only needed when you're specifying
arguments/properties.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Aug 8 '06 #3
Play with this code.
http://msdn2.microsoft.com/en-us/lib...te(d=ide).aspx

chanmm

"Tony Johansson" <jo*****************@telia.comwrote in message
news:D5******************@newsb.telia.net...
Hello!

I have two questions about attribute.
If you want to associate an attribute with a class you put the attribute
just before the class definition.
Like this
[myAttribute()]
public class myClass
{//some code here }

I know that it's possible to associate an attribute with an assembly.
But if you want to associate an attribute with an assembly where do you
put the attribute then?
My second question about attribute is it the same if I write the attribute
like this
[myAttribute()]
or
like this
[myAttribute]

//Tony


Aug 8 '06 #4

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

Similar topics

54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
12
by: Zunbeltz Izaola | last post by:
Hi I'm starting a new proyect and i'm in doubt about diferent interfaces for my clases. My clases will have a lot of attributes and i'm want to know what aproach could be the best 1) Define...
28
by: David MacQuigg | last post by:
I'm concerned that with all the focus on obj$func binding, &closures, and other not-so-pretty details of Prothon, that we are missing what is really good - the simplification of classes. There are...
4
by: Ben | last post by:
Consider: class foo: x = 5 def getx(r): a = foo() if r != 0: a.x = r return a
19
by: Gérard Talbot | last post by:
posted to: alt.html and comp.infosystems.www.authoring.html followup-to: comp.infosystems.www.authoring.html Hello all, I have 2 questions about validations. 1- What's basically the...
10
by: Jon Noring | last post by:
Out of curiosity, may a CDATA section appear within an attribute value with datatype CDATA? And if so, how about other attribute value datatypes which accept the XML markup characters? To me,...
161
by: KraftDiner | last post by:
I was under the assumption that everything in python was a refrence... so if I code this: lst = for i in lst: if i==2: i = 4 print lst I though the contents of lst would be modified.....
3
by: redefined.horizons | last post by:
I've been reading about Python Classes, and I'm a little confused about how Python stores the state of an object. I was hoping for some help. I realize that you can't create an empty place holder...
2
by: KJ | last post by:
Hello All, I am wondering about attributes: in the Framework, they all seem to end in the word Attribute, for example, BindableAttribute. But when you use them, you can either code...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.