TernaryIf Method
Definition
TernaryIf<TResult>(bool, Func<TResult>, Func<TResult>)
Returns one of two values depending on the value of condition.
public static TResult TernaryIf<TResult>(bool condition, Func<TResult> firstExpression, Func<TResult> secondExpression)
Parameters
conditionboolWhen
true, thefirstExpressionis invoked and becomes the result; whenfalse, thesecondExpressionis invoked and becomes the result.firstExpressionFunc<TResult>The function delegate that is invoked when
conditionistrue.secondExpressionFunc<TResult>The function delegate that is invoked when
conditionisfalse.
Returns
- TResult
The result of either function delegate
firstExpressionor function delegatesecondExpression.
Type Parameters
TResultThe type of the result.
TernaryIf<T, TResult>(bool, Func<T, TResult>, Func<T, TResult>, T)
Returns one of two values depending on the value of condition.
public static TResult TernaryIf<T, TResult>(bool condition, Func<T, TResult> firstExpression, Func<T, TResult> secondExpression, T arg)
Parameters
conditionboolWhen
true, thefirstExpressionis invoked and becomes the result; whenfalse, thesecondExpressionis invoked and becomes the result.firstExpressionFunc<T, TResult>The function delegate that is invoked when
conditionistrue.secondExpressionFunc<T, TResult>The function delegate that is invoked when
conditionisfalse.argTThe parameter of the function delegates
firstExpressionandsecondExpression.
Returns
- TResult
The result of either function delegate
firstExpressionor function delegatesecondExpression.
Type Parameters
TThe type of the parameter of the function delegates
firstExpressionandsecondExpression.TResultThe type of the result.
TernaryIf<T1, T2, TResult>(bool, Func<T1, T2, TResult>, Func<T1, T2, TResult>, T1, T2)
Returns one of two values depending on the value of condition.
public static TResult TernaryIf<T1, T2, TResult>(bool condition, Func<T1, T2, TResult> firstExpression, Func<T1, T2, TResult> secondExpression, T1 arg1, T2 arg2)
Parameters
conditionboolWhen
true, thefirstExpressionis invoked and becomes the result; whenfalse, thesecondExpressionis invoked and becomes the result.firstExpressionFunc<T1, T2, TResult>The function delegate that is invoked when
conditionistrue.secondExpressionFunc<T1, T2, TResult>The function delegate that is invoked when
conditionisfalse.arg1T1The first parameter of the function delegates
firstExpressionandsecondExpression.arg2T2The second parameter of the function delegates
firstExpressionandsecondExpression.
Returns
- TResult
The result of either function delegate
firstExpressionor function delegatesecondExpression.
Type Parameters
T1The type of the first parameter of the function delegates
firstExpressionandsecondExpression.T2The type of the second parameter of the function delegates
firstExpressionandsecondExpression.TResultThe type of the result.
TernaryIf<T1, T2, T3, TResult>(bool, Func<T1, T2, T3, TResult>, Func<T1, T2, T3, TResult>, T1, T2, T3)
Returns one of two values depending on the value of condition.
public static TResult TernaryIf<T1, T2, T3, TResult>(bool condition, Func<T1, T2, T3, TResult> firstExpression, Func<T1, T2, T3, TResult> secondExpression, T1 arg1, T2 arg2, T3 arg3)
Parameters
conditionboolWhen
true, thefirstExpressionis invoked and becomes the result; whenfalse, thesecondExpressionis invoked and becomes the result.firstExpressionFunc<T1, T2, T3, TResult>The function delegate that is invoked when
conditionistrue.secondExpressionFunc<T1, T2, T3, TResult>The function delegate that is invoked when
conditionisfalse.arg1T1The first parameter of the function delegates
firstExpressionandsecondExpression.arg2T2The second parameter of the function delegates
firstExpressionandsecondExpression.arg3T3The third parameter of the function delegates
firstExpressionandsecondExpression.
Returns
- TResult
The result of either function delegate
firstExpressionor function delegatesecondExpression.
Type Parameters
T1The type of the first parameter of the function delegates
firstExpressionandsecondExpression.T2The type of the second parameter of the function delegates
firstExpressionandsecondExpression.T3The type of the third parameter of the function delegates
firstExpressionandsecondExpression.TResultThe type of the result.
TernaryIf<T1, T2, T3, T4, TResult>(bool, Func<T1, T2, T3, T4, TResult>, Func<T1, T2, T3, T4, TResult>, T1, T2, T3, T4)
Returns one of two values depending on the value of condition.
public static TResult TernaryIf<T1, T2, T3, T4, TResult>(bool condition, Func<T1, T2, T3, T4, TResult> firstExpression, Func<T1, T2, T3, T4, TResult> secondExpression, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
Parameters
conditionboolWhen
true, thefirstExpressionis invoked and becomes the result; whenfalse, thesecondExpressionis invoked and becomes the result.firstExpressionFunc<T1, T2, T3, T4, TResult>The function delegate that is invoked when
conditionistrue.secondExpressionFunc<T1, T2, T3, T4, TResult>The function delegate that is invoked when
conditionisfalse.arg1T1The first parameter of the function delegates
firstExpressionandsecondExpression.arg2T2The second parameter of the function delegates
firstExpressionandsecondExpression.arg3T3The third parameter of the function delegates
firstExpressionandsecondExpression.arg4T4The fourth parameter of the function delegates
firstExpressionandsecondExpression.
Returns
- TResult
The result of either function delegate
firstExpressionor function delegatesecondExpression.
Type Parameters
T1The type of the first parameter of the function delegates
firstExpressionandsecondExpression.T2The type of the second parameter of the function delegates
firstExpressionandsecondExpression.T3The type of the third parameter of the function delegates
firstExpressionandsecondExpression.T4The type of the fourth parameter of the function delegates
firstExpressionandsecondExpression.TResultThe type of the result.
TernaryIf<T1, T2, T3, T4, T5, TResult>(bool, Func<T1, T2, T3, T4, T5, TResult>, Func<T1, T2, T3, T4, T5, TResult>, T1, T2, T3, T4, T5)
Returns one of two values depending on the value of condition.
public static TResult TernaryIf<T1, T2, T3, T4, T5, TResult>(bool condition, Func<T1, T2, T3, T4, T5, TResult> firstExpression, Func<T1, T2, T3, T4, T5, TResult> secondExpression, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
Parameters
conditionboolWhen
true, thefirstExpressionis invoked and becomes the result; whenfalse, thesecondExpressionis invoked and becomes the result.firstExpressionFunc<T1, T2, T3, T4, T5, TResult>The function delegate that is invoked when
conditionistrue.secondExpressionFunc<T1, T2, T3, T4, T5, TResult>The function delegate that is invoked when
conditionisfalse.arg1T1The first parameter of the function delegates
firstExpressionandsecondExpression.arg2T2The second parameter of the function delegates
firstExpressionandsecondExpression.arg3T3The third parameter of the function delegates
firstExpressionandsecondExpression.arg4T4The fourth parameter of the function delegates
firstExpressionandsecondExpression.arg5T5The fifth parameter of the function delegates
firstExpressionandsecondExpression.
Returns
- TResult
The result of either function delegate
firstExpressionor function delegatesecondExpression.
Type Parameters
T1The type of the first parameter of the function delegates
firstExpressionandsecondExpression.T2The type of the second parameter of the function delegates
firstExpressionandsecondExpression.T3The type of the third parameter of the function delegates
firstExpressionandsecondExpression.T4The type of the fourth parameter of the function delegates
firstExpressionandsecondExpression.T5The type of the fifth parameter of the function delegates
firstExpressionandsecondExpression.TResultThe type of the result.