你的位置:首页 > 软件开发 > ASP.net > C#复习③

C#复习③

发布时间:2016-06-16 13:00:17
C#复习③2016年6月16日11:13Main Declaration & Statement 声明和语句1.一个程序包含的声明空间有哪些?Namespace : declarations of classes , interfaces, structs, enums, ...

C#复习③

2016年6月16日

11:13

Main Declaration & Statement 声明和语句

1.一个程序包含的声明空间有哪些?

Namespace : declarations of classes , interfaces, structs, enums, delegates

命名空间:声明类、接口、结构体、枚举、委托

Class & interface & struct:declarations of fields, methods…

类 & 接口 & 结构体:声明字段、方法等

enumeration: declarations of enumeration constants

枚举: 声明枚举常量

Method block:declarations of local variables

方法块:声明局部变量

C#复习③

2.规则:

域规则:

No name may be declared more than once in the same declaration space 同一个声明空间内不能存在相同的命名。

However, it may be redeclared in an inner declaration space (except in a nested statement block)

但是,相同的命名可以在内部嵌套进行多次的声明

可见性规则:

Names declared in a method are visible from their declaration until the end of the method. 一个在方法内声明的命名,其生命期限从从声明开始到该方法的结束为期生命空间。

If a name is redeclared in an inner declaration space, it hides the same name from the outer declaration space. 如果在内部嵌套的声明空间中存在一个与外部空间相同的命名,则在内部空间该命名会将外部的命名覆盖掉。

In general, no name is visible outside its declaration space.通常情况下,没有命名能够在其声明空间之外可见。

3.Namespace 命名空间

可以嵌套其他的命名空间;内部可以包含多个枚举、多个类、多个接口;

存在嵌套命名空间时,内部的命名空间需要通过外部命名空间加上点“.”运算符进行调取。

C#复习③

C#复习③

4.Classes & Interface & Structs & Enumeration 类、接口、结构体和枚举

C#复习③

5. Statement Blocks 声明块

可以包括多个不同的平行作用域以及嵌套作用域。

C#复习③

6.Declaration of Local Variables 声明局部变量

局部变量对全局变量的覆盖,以及不同变量的存在空间

C#复习③

7.Simple Statement 简单语句

空语句 ;

赋值语句 sum + = x ;

方法调用:get='_blank'>string []parts = s.Split(',');

8.if Statement if语句

C#复习③

9.switch Statement switch 语句

能够作为跳转表达式的类型:integer type,char ,enum

switch  case语句适用于从一组互斥的分支中选择一个执行分支。

值得注意的就是case的值必须是常量表达式不允许是变量。

在C#中,switch语句的一个有趣的地方是case子句的排放更灵活,甚至可以将default子句放在最前面(因为任何两个case都不能相同)。

C#复习③

C#复习③

10.Loops 循环语句

while循环语句

do while循环

for循环

C#复习③

11.foreach Statement foreach 语句

C#复习③

12.Jump 跳转语句

C#复习③

13.return Statement 返回语句

C#复习③

14.output to the Console 输出到控制台

C#复习③

15.Formatting Codes for numbers 数字格式化

C#复习③

16.Formatted Output to a File格式输出到文件

C#复习③

17.Keyboard Input键盘输入

C#复习③

18.Input from a File从文件读取

C#复习③

19.Reading Command-line Parameters 读取命令行参数

C#复习③


原标题:C#复习③

关键词:C#

C#
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录