0
In c# can the conditional operator replace the if-else statement
5 Respostas
+ 4
I am wondering how would we use conditional operator in place of if else ?
a==b won't do anything alone
You need an if to check ,
if(a==b) then do something
likewise a&&b does nothing ,I mean it will definitely give output as true or false but if you want to do something based on that you still need to use if else ,
Am I wrong ? Or can anyone give an example!
+ 3
😐😐
Geez!
0
Nasif Rahman in what situation can I not use the conditional operator in place of the if-else conditional operator
0
A ternary operator ? : is an irregular exception in this case, because other than ternary operator, AFAIK there is no other logical operator which allows a way for simulating what an if-else block does.