What does square bracket [] mean in the below code?

Hojo picture Hojo · Mar 10, 2010 · Viewed 20.7k times · Source

I got below code from http://msdn.microsoft.com/en-us/library/dd584174(office.11).aspx for adding custom property in webpart tool pane. What does square bracket ([]) mean in the below code?

[Category("Custom Properties")]
        [WebPartStorage(Storage.Personal)]
        [FriendlyNameAttribute("Custom Color")]
        [Description("Select a color from the dropdown list.")]
        [Browsable(true)]
        [XmlElement(typeof(System.Drawing.KnownColor))]
        public System.Drawing.KnownColor MyColor
        {
            get
            {
                return _myColor;
            }
            set
            {
                _myColor = value;
            }
        }

Answer

Spencer Ruport picture Spencer Ruport · Mar 10, 2010

They're called attributes.

Here's a quick example of how they can be used: http://www.codeproject.com/KB/cs/attributes.aspx