14 Jun

Most Useful and Most Commonly Used Attributes in C#

This example shows the attributes that are most commonly used and most useful in C#.

        //mark types and members of types that should no longer be used
        [Obsolete("Don't use")]

        //Specifies the display name for a property, event, or public void method which takes no arguments.
        [DisplayName("Web Site Url")]

        //Specifies a description for a property or event.
        [Description("Web site url description")]

        //Specifies the default value for a property.

        //indicates that a class can be serialized. This class cannot be inherited.

        //controls XML serialization of the attribute target as an XML root element.

        //indicates that a public field or property represents an XML element when the XmlSerializer serializes or deserializes the object that contains it.

        //specifies that the XmlSerializer must serialize the class member as an XML attribute.

        //instructs the Serialize method of the XmlSerializer not to serialize the public field or public read/write property value.

        //controls accessibility of an individual managed type or member, or of all types within an assembly, to COM.

        //which allows you to hide properties

        //tells the designer to expand the properties which are classes 

Leave a Reply

Your email address will not be published. Required fields are marked *