is there a faq about the square bracket thingies in c#

A

alexl

hi,

is there a faq that explains what the square brackets are and what are
the available keywords you can use in them?

e.g.

[System.Security.Permissions.PermissionSet
(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void WndProc(ref Message m)
{
 
J

Jeff Johnson

is there a faq that explains what the square brackets are and what are
the available keywords you can use in them?

e.g.

[System.Security.Permissions.PermissionSet
(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void WndProc(ref Message m)
{

What you're seeing there is known as an Attribute. Documentation here:

(VS 2005) http://msdn.microsoft.com/en-us/library/z0w1kczw(VS.80).aspx
(VS 2008) http://msdn.microsoft.com/en-us/library/z0w1kczw.aspx
 
J

Jeff Johnson

is there a faq that explains what the square brackets are and what are
the available keywords you can use in them?

e.g.

[System.Security.Permissions.PermissionSet
(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void WndProc(ref Message m)
{

What you're seeing there is known as an Attribute. Documentation here:

(VS 2005) http://msdn.microsoft.com/en-us/library/z0w1kczw(VS.80).aspx
(VS 2008) http://msdn.microsoft.com/en-us/library/z0w1kczw.aspx

Forgot to add: as far a getting a list of what's available for what...good
luck. I've never seen any documentation that says something like "This
class/function/whatever can be modifed with the following attributes: ..."
Your best bet is probably to look through a namespace and find any type with
"Atribute" on the end and then read its description.
 
B

Ben Voigt [C++ MVP]

Jeff said:
is there a faq that explains what the square brackets are and what
are the available keywords you can use in them?

e.g.

[System.Security.Permissions.PermissionSet
(System.Security.Permissions.SecurityAction.Demand,
Name="FullTrust")] protected override void WndProc(ref
Message m) {

What you're seeing there is known as an Attribute. Documentation
here: (VS 2005)
http://msdn.microsoft.com/en-us/library/z0w1kczw(VS.80).aspx (VS
2008) http://msdn.microsoft.com/en-us/library/z0w1kczw.aspx

Forgot to add: as far a getting a list of what's available for
what...good luck. I've never seen any documentation that says
something like "This class/function/whatever can be modifed with the
following attributes: ..." Your best bet is probably to look through
a namespace and find any type with "Atribute" on the end and then
read its description.

But while it's good practice to name attribute classes ending in
"Attribute", it's not required. Better to use .NET Reflector to list all
classes inheriting from Attribute.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top