System.Object Value { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Value property of the DefaultValueAttribute class represents the default value assigned to a property or field. This attribute is used to specify the initial value of a property, especially when the default value is not a simple number or string, such as in the case of structs like vectors or colors.

Usage

To use the DefaultValueAttribute, apply it to a property or field in your class. This is particularly useful when you want to ensure that the default value is accessible via reflection, or when code generation cannot automatically determine the default value.

Example

// Example of using DefaultValueAttribute
public class MyComponent : Component
{
    [DefaultValue(10)]
    public int MyProperty { get; set; } = 10;

    [DefaultValue("DefaultString")]
    public string MyStringProperty { get; set; } = "DefaultString";

    [DefaultValue(typeof(Vector3), "0,0,0")]
    public Vector3 MyVectorProperty { get; set; } = new Vector3(0, 0, 0);
}