Ternary operators can be use full when we have only one simple if else condition.
Ternary Operator Syntax:
Ternary Operator Syntax:
condition ? first_expression : second_expression;
Ex:
public class TernaryEx
{
public int GetBigNum(int a, int b)
{
return a > b ? a : b;
//in the above syntax if a is greater than b
//the above expression returns a else it returns b.
}
}
Note: SignUp for JobGuaranteed Training
No comments:
Post a Comment