Operator
Example
Meaning in Life
&&
if((age == 30) && (name == "Fred"))
Conditional AND operator
||
if((age == 30) || (name == "Fred"))
Conditional OR operator
!
if(!myBool)
Conditional NOT operator
The switch Statement
The other simple selection construct offered by C# is the switch statement. As in other C-based
languages, the switch statement allows you to handle program flow based on a predefined set of
choices. For example, the following Main() logic prints a specific string message based on one of
two possible selections (the default case handles an invalid selection):
Do'stlaringiz bilan baham: |