mercredi 24 avril 2019

Single line If condition with else with operator

How can we write a single line If condition without else in the operator?

Example:

If(count==0) { count=2; }

How can we write above like below:

count=count==0?2;

As ternary operator requires if else condition. I want to do it without the ternery operator. Is there any operator available in C#?

Thanks.

Aucun commentaire:

Enregistrer un commentaire