Hi,
Is there a way to stop a function from returning a value if a condition evaluates to true.
For example my function returns the sum of two integers. How can I stop it from returning anything if one of the integers is negative
Class C1
{
...
public int Sum(int a, int b)
{
if((a<0)||(b<0))
{
trow new Exception();
}
else
{
return a+b;
}
}
}
I don't want my program to crash if a or b is negative, but I also don't want the function to return value