I am switching from an Arduino (c language) to a Netduino (c# language).
In my arduino program I have the following function (built-in):
I would like to convert this to C#. I have the following code:
int ConstrainValue(int value, int min, int max)
{
int Value = value;
int Min = min;
int Max = max;
if (Value >= Max)
{
Value = Max;
return Value;
}
else if (Value <= Max)
{
Value = Min;
return Value;
}
return Value;
}
However, I would also like to be able to use this for the double
datatype. Is it possible to modify the function so multiple datatypes can be used?