分類 | C# 關鍵字 |
Declaration statements | xx=2 |
Expression statements | area = 3.14 * (radius * radius); |
Selection statements | if、else、switch、case |
Iteration statements | do、for、foreach、in、while |
Jump statements | break、continue、default、goto、return、yield |
Exception handling statements | throw、try-catch、try-finally、try-catch-finally |
static void Main() { // Declaration statement. int counter; // Assignment statement. counter = 1; // Error! This is an expression, not an expression statement. // counter + 1; // Declaration statements with initializers are functionally // equivalent to pointA declaration statement followed by assignment statement: int[] radii = { 15, 32, 108, 74, 9 }; // Declare and initialize an array. const double pi = 3.14159; // Declare and initialize pointA constant. // foreach statement block that contains multiple statements. foreach (int radius in radii) { // Declaration statement with initializer. double circumference = pi * (2 * radius); // Expression statement (method invocation). A single-line // statement can span multiple text lines because line breaks // are treated as white space, which is ignored by the compiler. System.Console.WriteLine("Radius of circle #{0} is {1}. Circumference = {2:N2}", counter, radius, circumference); // Expression statement (postfix increment). counter++; } // End of foreach statement block } // End of Main method body.} // End of SimpleStatements class.閱讀全文...
