DefaultValueAttribute Class

May 11, 2014

Specifies the default value for a property.

System.Object
  System.Attribute
    System.ComponentModel.DefaultValueAttribute

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

[AttributeUsageAttribute(AttributeTargets.All)]
public class DefaultValueAttribute : Attribute

The DefaultValueAttribute type exposes the following members.

  NameDescription
Public methodDefaultValueAttribute(Boolean)Initializes a new instance of the DefaultValueAttribute class using a Boolean value.
Public methodDefaultValueAttribute(Byte)Initializes a new instance of the DefaultValueAttribute class using an 8-bit unsigned integer.
Public methodDefaultValueAttribute(Char)Initializes a new instance of the DefaultValueAttribute class using a Unicode character.
Public methodDefaultValueAttribute(Double)Initializes a new instance of the DefaultValueAttribute class using a double-precision floating point number.
Public methodDefaultValueAttribute(Int16)Initializes a new instance of the DefaultValueAttribute class using a 16-bit signed integer.
Public methodDefaultValueAttribute(Int32)Initializes a new instance of the DefaultValueAttribute class using a 32-bit signed integer.
Public methodDefaultValueAttribute(Int64)Initializes a new instance of the DefaultValueAttribute class using a 64-bit signed integer.
Public methodDefaultValueAttribute(Object)Initializes a new instance of the DefaultValueAttribute class.
Public methodDefaultValueAttribute(Single)Initializes a new instance of the DefaultValueAttribute class using a single-precision floating point number.
Public methodDefaultValueAttribute(String)Initializes a new instance of the DefaultValueAttribute class using a String.
Public methodDefaultValueAttribute(Type, String)Initializes a new instance of the DefaultValueAttribute class, converting the specified value to the specified type, and using an invariant culture as the translation context.
Top

  NameDescription
Public propertyValueGets the default value of the property this attribute is bound to.
Top

  NameDescription
Public methodEqualsReturns whether the value of the given object is equal to the current DefaultValueAttribute. (Overrides Attribute.Equals(Object).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeReturns the hash code for this instance. (Overrides Attribute.GetHashCode().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodMatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodSetValueSets the default value for the property to which this attribute is bound.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

You can create a DefaultValueAttribute with any value. A member's default value is typically its initial value. A visual designer can use the default value to reset the member's value. Code generators can use the default values also to determine whether code should be generated for the member.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Show:
© 2014 Microsoft