I am aware of interfaces, methods, classes and properties. what are attributes?
any sites that would give good introduction about attributes in c#?
thanks
nath
Printable View
I am aware of interfaces, methods, classes and properties. what are attributes?
any sites that would give good introduction about attributes in c#?
thanks
nath
Attributes control how a type or member interacts with the IDE, compiler, etc. Attributes themselves are classes. Take for example the System.ComponentModel.CategoryAttribute class. You apply it to a property declaration and it controls which category the property appears under in the Properties window at design time. Note that all attribute classes inherit the Attribute class, either directly or indirectly, and it is convention to end their name in "Attribute". When you apply an attribute in code you normally drop the "Attribute" suffix. For instance, this code:produced the result below when an instance of the class was added to a form in the designer.Code:using System;
using System.Collections.Generic;
using System.Text;
namespace WindowsApplication2
{
class MyTextBox : System.Windows.Forms.TextBox
{
private string _version = "1.0.0.0";
[System.ComponentModel.Category("Wunnell")]
public string Version
{
get { return _version; }
}
}
}
and also give a simple example.
VB Code:
and also give a simple example.
thanks jm
In addition: Attributes are a way of specifying certain types of Metadata.
popski,
that was a great reply. the link was a great resource.
thanks jm
nath