Description
The MaxValue
property of the MinMaxAttribute
class specifies the maximum allowable value for a property that is decorated with this attribute. This is useful for defining constraints on numeric properties, ensuring that they do not exceed a specified upper limit.
Usage
To use the MaxValue
property, apply the MinMaxAttribute
to a property in your class, and specify the maximum value that the property should not exceed. This is typically used in conjunction with the MinValue
property to define a range.
Example
// Example of using MinMaxAttribute with MaxValue
public class ExampleComponent : Component
{
[MinMax(0, 100)]
public float Health { get; set; }
public ExampleComponent()
{
Health = 50; // Initial value within the range
}
}