Description
The MinValue
property of the MinMaxAttribute
class specifies the minimum allowable value for a property that is decorated with this attribute. This is useful for ensuring that a property value does not fall below a certain threshold, which can be critical for maintaining valid state or behavior in your application.
Usage
To use the MinValue
property, apply the MinMaxAttribute
to a property in your class, specifying the minimum and maximum values. This attribute can be used to enforce constraints on the values that a property can take.
Example
// Example of using MinMaxAttribute with MinValue
public class ExampleComponent : Component
{
[MinMax(0.0f, 100.0f)]
public float Health { get; set; }
public ExampleComponent()
{
Health = 50.0f; // Initial value within the specified range
}
}