It is necessary to check the division by zero inside the lambda bends!
double Div(double a, double b) => a / b;
It is necessary to check the division by zero inside the lambda bends!
double Div(double a, double b) => a / b;
For example, you can do it with a ternary operator, like this:
double Div(double a, double b) => b != 0 ? a / b : 0; If you have the second parameter ( b ) zero, it will return zero. Returned zero is just an example. Operator ?: Is a ternary operator. You can read here: Operator?: (Reference book on C #)
Source: https://ru.stackoverflow.com/questions/626835/
All Articles