How To Call C# If Else In A Single LinePankaj Pandey7yPublished Apr 10, 2013, 12:00 AMUpdated Aug 21, 2019, 1:53 AM95.6k05Reactions×25BlogHere is the syntax of using C# if else statement in a single line. (Condition) ? "Value For true":" Value For False " OK, here is your typical if else statement: if(x==1) { x=10; } else { x=15; } This is how we can replace the above code block in a single line: x=(x==1)?10:15; Here is a detailed tutorial, How To Use C# If Else Statement
Join the conversation! Your thoughts help the community grow.