How can I enforce that the variable of a class can be set within a particular numerical range? For example, in my sample code below, I would like to enforce that the user can only be able to set a value between 0.0f to 1.0f for the variable DownsamplingScale
.
public sealed class DownsampleData
{
public float DownsamplingScale = 0.0f;
}
I am not looking for the Clamping type solution because I really need to tell the class user that he/she must set a value within the range of 0.0f to 1.0f at the time they are using my class (writing code i.e. before compilation).
There are several ways to deal with the situation during runtime. I need something that informs during/before compilation about the expected range.