zoukankan      html  css  js  c++  java
  • C#复习③

    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

    方法块:声明局部变量

    clip_image001

    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 命名空间

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

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

    clip_image002

    clip_image003

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

    clip_image004

    5. Statement Blocks 声明块

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

    clip_image005

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

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

    clip_image006

    7.Simple Statement 简单语句

    空语句 ;

    赋值语句 sum + = x ;

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

    8.if Statement if语句

    clip_image007

    9.switch Statement switch 语句

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

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

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

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

    clip_image008

    clip_image009

    10.Loops 循环语句

    while循环语句

    do while循环

    for循环

    clip_image010

    11.foreach Statement foreach 语句

    clip_image011

    12.Jump 跳转语句

    clip_image012

    13.return Statement 返回语句

    clip_image013

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

    clip_image014

    15.Formatting Codes for numbers 数字格式化

    clip_image015

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

    clip_image016

    17.Keyboard Input键盘输入

    clip_image017

    18.Input from a File从文件读取

    clip_image018

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

    clip_image019

    C#复习④摘要: 方法、函数、过程、静态变量、类、结构体、构造函数、析构函数、运算符重载、索引器、类型转换重载、嵌套类型

    C#复习④友情链接:http://www.cnblogs.com/zpfbuaa/p/5590961.html

  • 相关阅读:
    分享2021年陆陆续续看过的电影-附电影名单
    LEPUS开源数据库监控系统-开源的MySQL/Oracle/MongoDB/Redis一站式数据库专业级性能监控系统
    分享2021年陆陆续续读过的书-附书单
    Jmeter压测报错:Non HTTP response code: java.net.ConnectExceptionexception的解决办法
    adb安装apk包时提示:device unauthorized
    Pyhton AES_cbc解密
    appium— Android定位webView里面的UI元素
    appium自动化测试实战
    Appium + Python环境搭建(移动端自动化)
    selenium自动化定位方法
  • 原文地址:https://www.cnblogs.com/zpfbuaa/p/5590617.html
Copyright © 2011-2022 走看看