Possible Duplicate:
Meaning of text between square brackets
The class I'm looking at looks like
public class SaveBundle
{
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public SaveBundleHeader Header
{
get
{
return this.headerField;
}
set
{
this.headerField = value;
}
}
}
I don't know why the [System.Xml.Serialisztion.Xml etc] exists or what it is called to research it further?
Can some one tell me the name of [] and what in this example it's purpose is?
It's an attribute, used to decorate things with accessible metadata. You can use reflection to get at this data and do something with it. Many parts of the framework already do this, as with the example in the MSDN link for attributes marking a class Serializable
- you could do custom serialization based on metadata but you don't always need to because 'auto-serialization' is already implemented based on this concept.
The square brackets are the syntax used to apply them, as demonstrated in your example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With