return
- Last UpdatedApr 24, 2024
- 1 minute read
The return statement terminates the execution of the method and returns to the caller the control and the function's result, if any. In fact, return statement can be used with an expression, if the method has a return type and computes a value. The expression must be implicitly convertible to the return type of the method. However, return statement can be used without expression if the method doesn't compute a value. In async methods, return statement is usually used to terminate the method execution earlier.
If a method doesn't contain the return statement, it terminates after its last statement is executed.
Example code
static bool testConditionReturn()
{
return false;
}