A C # "class/struct/enum" definition does not require a terminating semicolon.
public sealed class Hiker
{
...
//No; it's right.
However, you can use a terminating semicolon but have no effect on the program:
public sealed class Hiker
{
...
}; Yes, it's OK, but not recommended.
In Java, the definition of a function can have a trailing semicolon, but is not allowed in C #.
public sealed class Hiker
{
public void Hitch () {...}; ; it's not true.
//No; it's right.
5. Statement
Declaration is the introduction of variables 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);
}
}
It is illegal to declare a variable: This variable may not be used. For example:
if (...)
int x = 42; Compile-time error
Else
...
6. Expression type
The expression is used for calculation!
W each expression produces a value
W Each expression must have only unilateral effect
W each variable can be used only if it is assigned a value
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 one expression to read the value of a variable unless the compiler knows that the variable has already been initialized or has been assigned a value. For example, the following statement causes a compiler error:
int m;
if (...) {
m = 42;
}
Console.WriteLine (m);//Compiler error, because m may not be assigned
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.