I want to validate some doubles before executing the rest of the code. I have some double variables that should be checked if they are in the range else they should throw an exception. I am just wondering if this was a good practice by writing three if statements or do we have other good practices when we are trying to validate these values
public void Execute(Exam1 exam1, Exam2 exam2, Exam3 exam3)
{
if(Exam1.Value >= -100.0 && Exam1.Value <= 101.2)
{
///DO something
}
else
{
/// throw an exception
}
if(Exam2.Value >= -100.0 && Exam2.Value <= 101.2)
{
///DO something
}
else
{
/// throw an exception
}
if(Exam3.Value >= -100.0 && Exam3.Value <= 101.2)
{
///DO something
}
else
{
/// throw an exception
}
}