Here 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: