Name

DefaultValueAttribute

Synopsis

This attribute decorates a property to indicate its default value. The VS.NET designer will display a property that is set to its default value using a plain style, whereas non-default values will be displayed in bold.

You should ensure that the Value of the attribute matches the initial value assigned to the property, as code generators may choose not to persist default properties.


public sealed class DefaultValueAttribute : Attribute {

// Public Constructors

   public DefaultValueAttribute(bool value);

   public DefaultValueAttribute(byte value);

   public DefaultValueAttribute(char value);

   public DefaultValueAttribute(double value);

   public DefaultValueAttribute(short value);

   public DefaultValueAttribute(int value);

   public DefaultValueAttribute(long value);

   public DefaultValueAttribute(object value);

   public DefaultValueAttribute(float value);

   public DefaultValueAttribute(string value);

   public DefaultValueAttribute(Type type, string value);

// Public Instance Properties

   public object Value{get; }

// Public Instance Methods

   public override bool Equals(object obj);  // overrides Attribute

   public override int GetHashCode();  // overrides Attribute

}

Hierarchy

System.Object System.Attribute DefaultValueAttribute

Valid On

All

Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.