分享
 
 
 

15.4 Labeled statements

王朝other·作者佚名  2006-05-04
窄屏简体版  字體: |||超大  

blocks, but are not permitted as embedded statements.

labeled-statement:

identifier : statement

A labeled statement declares a label with the name given by the identifier.

The scope of a label is the whole

block in which the label is declared, including any nested blocks. It is a

compile-time error for two labels

with the same name to have overlapping scopes.

A label can be referenced from goto statements (§15.9.3) within the scope

of the label. [Note: This means

that goto statements can transfer control within blocks and out of blocks,

but never into blocks. end note]

Labels have their own declaration space and do not interfere with other

identifiers. [Example: The example

int F(int x) {

if (x >= 0) goto x;

x = -x;

x: return x;

}

is valid and uses the name x as both a parameter and a label. end example]

Execution of a labeled statement corresponds exactly to execution of the

statement following the label.

In addition to the reachability provided by normal flow of control, a

labeled statement is reachable if the

label is referenced by a reachable goto statement. (Exception: If a goto

statement is inside a try that

includes a finally block, and the labeled statement is outside the try, and

the end point of the finally

block is unreachable, then the labeled statement is not reachable from that

goto statement.)

15.5 Declaration statements

A declaration-statement declares a local variable or constant. Declaration

statements are permitted in blocks,

but are not permitted as embedded statements.

declaration-statement:

local-variable-declaration ;

local-constant-declaration ;

15.5.1 Local variable declarations

A local-variable-declaration declares one or more local variables.

local-variable-declaration:

type local-variable-declarators

Chapter 15 Statements

181

local-variable-declarators:

local-variable-declarator

local-variable-declarators , local-variable-declarator

local-variable-declarator:

identifier

identifier = local-variable-initializer

local-variable-initializer:

expression

array-initializer

The type of a local-variable-declaration specifies the type of the

variables introduced by the declaration.

The type is followed by a list of local-variable-declarators, each of which

introduces a new variable. A

local-variable-declarator consists of an identifier that names the

variable, optionally followed by an

.=. token and a local-variable-initializer that gives the initial value of

the variable.

The value of a local variable is obtained in an expression using a

simple-name (§14.5.2), and the value of a

local variable is modified using an assignment (§14.13). A local variable

must be definitely assigned (§12.3)

at each location where its value is obtained.

The scope of a local variable declared in a local-variable-declaration is

the block in which the declaration

occurs. It is an error to refer to a local variable in a textual position

that precedes the local-variabledeclarator

of the local variable. Within the scope of a local variable, it is a

compile-time error to declare

another local variable or constant with the same name.

A local variable declaration that declares multiple variables is equivalent

to multiple declarations of single

variables with the same type. Furthermore, a variable initializer in a

local variable declaration corresponds

exactly to an assignment statement that is inserted immediately after the

declaration.

[Example: The example

void F() {

int x = 1, y, z = x * 2;

}

corresponds exactly to

void F() {

int x; x = 1;

int y;

int z; z = x * 2;

}

end example]

15.5.2 Local constant declarations

A local-constant-declaration declares one or more local constants.

local-constant-declaration:

const type constant-declarators

constant-declarators:

constant-declarator

constant-declarators , constant-declarator

constant-declarator:

identifier = constant-expression

The type of a local-constant-declaration specifies the type of the

constants introduced by the declaration.

The type is followed by a list of constant-declarators, each of which

introduces a new constant. A constantdeclarator

consists of an identifier that names the constant, followed by an .=.

token, followed by a

constant-expression (§14.15) that gives the value of the constant.

C# LANGUAGE SPECIFICATION

182

The type and constant-expression of a local constant declaration must

follow the same rules as those of a

constant member declaration (§17.3).

The value of a local constant is obtained in an expression using a

simple-name (§14.5.2).

The scope of a local constant is the block in which the declaration occurs.

It is an error to refer to a local

constant in a textual position that precedes its constant-declarator.

Within the scope of a local constant, it is

a compile-time error to declare another local variable or constant with the

same name.

A local constant declaration that declares multiple constants is equivalent

to multiple declarations of single

constants with the same type.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有