.NET DefaultValue attribute

The place where I typically used DefaultValue is for classes which are serialized/deserialized to XML. It does not set the default value during instantiation and doesn’t impact autoproperties.

From MSDN:

A DefaultValueAttribute will not cause a member to be automatically initialized with the attribute’s value. You must set the initial value in your code.

MSDN – DefaultValueAttribute Class


Edit: As Roland points out, and as others mentioned in their answers the attribute is also used by the Form Designer

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)