Corrected grammar in C# Ternary operator article (#20684)

This commit is contained in:
Karol Skrobot
2018-10-31 17:02:16 +00:00
committed by Ian Duke
parent 5989ae02f0
commit 296ea16feb

View File

@ -3,7 +3,7 @@ title: Ternary operator
--- ---
# Ternary operator (`?:`) # Ternary operator (`?:`)
Ternary operator return one of the two expression based on the condition. It can be used as a shortcut for if...else statement. Ternary operator returns one of the two expressions based on a condition. It can be used as a shortcut for if...else statement.
## Syntax ## Syntax
``` ```
@ -22,9 +22,9 @@ Returned if `condition_expression` is false.
## Example ## Example
``` ```
// initialize - set true or false here to view different result // initialize - set true or false here to view different result
bool hasFreeSweet = false; bool hasFreeSweets = false;
string str = hasFreeSweet ? "Free sweet!" : "No free sweet."; string str = hasFreeSweets ? "Free sweets!" : "No free sweets.";
//output in console //output in console
Console.WriteLine(str); Console.WriteLine(str);
@ -32,9 +32,9 @@ Console.WriteLine(str);
## Output ## Output
``` ```
if hasFreeSweet == true if hasFreeSweets == true
> Free sweet! > Free sweets!
if hasFreeSweet == false if hasFreeSweets == false
> No free sweet. > No free sweets.
``` ```