Search C # (former speech) a week
C # Talent Bird (QQ: 249178521)
4. Panpoint symbol
{And} composition block
The semicolon represents the end of a statement
Using system;
Public Sealed Class Hiker
{
Public static void
Main
()
{
Int result;
Result = 9 * 6;
Int thirteen;
Thirteen = 13;
Console.write (Result / Thirteen);
Console.write (Result% Thirteen);
}
}
A C # "class / structure / enumeration" definition does not require a termination semicolon.
Public Sealed Class Hiker
{
...
} // Nothing; it is correct
However, you can use a termination semicolon, but there is no impact on the program:
Public Sealed Class Hiker
{
...
}; // has; yes, but not recommended
In Java, there is an end semicolon in the definition of a function, but is not allowed in C #.
Public Sealed Class Hiker
{
Public void hitch () {...}; //; is incorrect
} // Nothing; it is correct
5. Statement
The statement is introduced into a variable in a block.
u Each variable has an identifier and a type
u The type of each variable cannot be changed
Using system;
Public Sealed Class Hiker
{
Public static void
Main
()
{
Int result;
Result = 9 * 6;
Int thirteen;
Thirteen = 13;
Console.write (Result / Thirteen);
Console.write (Result% Thirteen);
}
}
This declares that a variable is illegal: this variable may not be used. E.g:
IF (...)
INT x = 42; // Compile time error
Else
...
6. Expression
Expressions are used to calculate!
W Each expression generates a value
W Each expression must only be single-sided
W can be used after each variable is only assigned
Using system;
Public Sealed Class Hiker
{
Public static void
Main
()
{
Int result;
Result = 9 * 6;
Int thirteen;
Thirteen = 13;
Console.write (Result / Thirteen);
Console.write (Result% Thirteen);
}
}
C # does not allow any expression to read variables unless the compiler knows that this variable has been initialized or has been assigned. For example, the following statement will cause compiler errors:
Int m;
IF (...) {
m = 42;
}
Console.WriteLine (m); // Compiler error, because M may not be assigned
7. Value
Type value explanation
Bool True False Boolean
FLOAT 3.14
Double 3.1415 double precision type
Char 'x' character type
INT 9 Integer String "Hello" string
Object Null object