Namespace consoleapplication1
{
Class Program
{
Enum holobby {Reading, writing, singing, dancing}
Static void main (string [] ARGs)
{
/* Condition Statement */
Int month;
Month = 0;
/* If statement */
// ① Syntax-If (Boolean) Program Statement
If (month <1)
{
Console. writeline ("the month does not exist! ");
}
// ② Syntax-If (Boolean) Program Statement A else Program Statement B
Month ++;
If (month = 1)
{
Console. writeline ("Today is July 22, January ");
Month ++;
}
Else
{
Console. writeline ("the month does not exist! ");
}
// ③ Syntax-If (Boolean) Program Statement A else if Program Statement B else if Program Statement C... ...
If (month = 1)
{
Console. writeline ("Today is July 22, January ");
}
Else if (month = 2)
{
Console. writeline ("Today is July 22, February ");
}
Else if (month = 3)
{
Console. writeline ("Today is July 22, March ");
}
Else
{
Console. writeline ("the month does not exist! ");
}
// Of course, you can also use multiple boolean values or the ternary operators in the previous section (? :)
/* Switch statement */
// Syntax:
// Switch (parameter)
//{
// Parameter value a corresponding to case: Operation A; break;
// Parameter value B corresponding to case: Operation B; break;
// Default: The default value is C and break;
//}
Int x = 0;
Switch (X)
{
Case 0: console. writeline ("x value: 0"); break;
Case 1: console. writeline ("x value: 1"); break;
Default: console. writeline ("Default execution status"); break;
}
Holobby myholobby = holobby. Dancing; // use of enumeration types -- do you forget to define the enumeration type parameter holobby at the beginning?
Switch (myholobby)
{
Case holobby. Dancing: console. writeline ("I like dancing! "); Break;
Case holobby. Reading: console. writeline ("I like reading! "); Break;
Case holobby. Singing: console. writeline ("I like singing! "); Break;
Case holobby. Writing: console. writeline ("I like writing! "); Break;
Default: console. writeline ("these are not my hobbies! "); Break;
}
Switch (myholobby) // use a combination of case
{
Case holobby. Dancing:
Case holobby. Reading: console. writeline ("I like reading and dancing! "); Break;
Case holobby. Singing:
Case holobby. Writing: console. writeline ("I like writing and singing! "); Break;
Default: console. writeline ("these are not my hobbies! "); Break;
}
Console. readkey (); // wait for the user to enter
}
}
}