Study Note:CSIN3 Chapter 2: C# Language Basic

2023-11-01

 
I should familiar with this chapter. If not, I should hit the wall.
 
2.1 A First C# Program
I'm very glad to see the first C# program is not a hello world program. :-)
The first program introduce the variable, method, Main, Class, Namespace.
Nothing important to me, I think.
 
2.2 Syntax
Identifiers: The name of the class, method, variable, namespace and so on. Start with Unicode character or under score. C# is case-sensitive.
Keywords: The words system choose which can't be an identifier, reserved word. You can use prefix @ to use a keyword as identifier. Then you can use it like "@class". But if you use prefix @ to a common identifier, the "@a" and "a" is the same.
Contextual Keywords: I don't know it exactly, maybe they are recognized as keywords in special area.
Literals: Data in the code.
Punctuators: Separator. E.g. , ; {}
Operators: Transform and combine expressions. E.g. + - * /
Comments: // single line comment /* */ multiline comment
 
I decide to not note all the things, it is too much to note, oops. I just note the useful information.
 
2.3 Type Basics
  1. Predefine types and Custom types
  2. Value types, Reference types and Pointer types
    • Different of value type and reference type
      • Memory allocate: value just an object, reference has a reference and an object
      • Copy: value copy the object, reference copy the reference means point the same object
     
  3. Struct is a Custom Value type
 
2.4 Numeric Types
Numeric Literal inference: I use to think is totally wrong.
If there is a decimal point then the literal is a double , else it is a int or long and so on
Checked and Unchecked operator
Real number rounding error: see some statements
decimal m = 1M / 6M;               // 0.1666666666666666666666666667M
double d = 1.0 / 6.0;             // 0.16666666666666666
decimal notQuiteWholeM = m+m+m+m+m+m; // 1.0000000000000000000000000002M
double notQuiteWholeD = d+d+d+d+d+d; // 0.99999999999999989
So don't use float or double to financial calculation, I think.
 
2.5 Boolean Type and Operators
Bool alias System.Boolean
Bool value can't convert to numeric types
Condition operators(&& || !) short-circuit evaluation when possible, &, | don't do short-circuit evaluation
 
2.6 Strings and Characters
Escape characters: /u Unicode
@: verbatim string
 
2.7 Arrays
Declaration:
C#: int[] array = new int[5]; In actually, int[] array is declaration, and new int[5] is initialize
C++: int array[5];
Default initialize: value type 0 or false and so on, reference type is null
Multidimensional array:
rectangular array: int[,] array = new int[3,3];
Jagged Array: int[][] array = new int[3][]; array[0] = new int[4];
Var: I think it will be introduce more in later chapter
 
2.8 Variables and Parameters
Memory allocate: stock and heap
Stock: local variables and parameters
Heap: New objects
Definite Assignment:
  • Local variables must be assigned a value before they can be read.
  • Function arguments must be supplied when a method is called.
  • All other variables (such as fields and array elements) are automatically initialized by the runtime.
Default Value:
Reference null
Numeric type or Enum type 0
char type '/0'
bool type false
Parameter pass style
None
 Value
Going in
Ref
 Reference
Going in
Out
 Reference
Going out
 
 
2.9 Expression and Operators
Operator Precedence
 
2.10 Statements
Goto in switch
Goto case 12;
 
2.11 Namespace
Some advantage feature: I don't think it is very import, and I don't know some of them well, NEED TO READ AGAIN
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Study Note:CSIN3 Chapter 2: C# Language Basic 的相关文章

随机推荐

  • JSON 按key的字符先后顺序排序

    话不多说直接上方法 var sortJson function obj callback var endValue item key keyArray keyArray2 o i len endValue keyArray keyArray
  • 一元线性回归分析的残差诊断

    1973年安斯库姆 Anscombe 构造了四组数据 用这四组数据得到的经验回归方程是相同的 都是y 3 00 0 500x 决定系数都是 r2 0 667 相关系数r 0 816 这四组数据所建的回归方程是相同的 决定系数r2 F统计量也
  • uboot中printf( )函数实现分析

    1 前言 这部分涉及uboot中串口的初始化 参考博客 uboot中串口 控制台 初始化详解 2 printf 函数实现思路分析 1 uboot中的printf 函数的用法和利用C库编写C语言程序时是一样的 本身uboot中printf 函
  • linux中的/etc/hosts.allow和/etc/hosts.deny详解

    linux中的 etc hosts allow和 etc hosts deny详解 当linux主机需要允许 禁止某些ip地址 地址段访问某些资源或服务时 etc hosts allow和 etc hosts deny就派上了用场 两个文件
  • tcp_transmit_skb的发送时机梳理

    在上文数据通过网络发送的过程中 当程序调用tcp sendmsg发送数据的时候有可能当前的数据不会马上发送出去 当前在哪些场景下会触发数据的发送呢 检查mtu 创建 一个新的路径MTU 发现段 未启用路径MTU 当前路径MTU探测段的长度不
  • Andriod期末复习总结

    一 安卓项目的目录结构 AndroidManifest xml 项目清单文件 设置应用名称 图标等属性 libs 项目依赖的外部库 src Java源文件 bin 目标文件 Java字节码 class 资源打包文件 ap 和Dalvik虚拟
  • 机器学习——SVM(支持向量机)与人脸识别

    忆如完整项目 代码详见github https github com yiru1225 转载标明出处 勿白嫖 star for projects thanks 目录 系列文章目录 一 SVM的概念与原理 1 SVM简介 2 SVM基本流程
  • JS中cookie的增删改查

    JS中对cookie进行增删改查 以下个人总结 如有错误 请指出修正 cookie简单介绍 cookie是一段有大小限制的文本信息 由于浏览器厂商不同 各个浏览器大小不一致 其伴随着用户请求和浏览器与Web服务器之间传递当用户访问站点时 W
  • 全国省市区编码表

    Excel转sql表 将Excel转换成支持导入的数据格式 本文用csv示例 使用Navicat工具导入我们的csv文件 选择对应的文件格式导入 然后执行下一步 然后就一直无限下一步 就导入成功了哦 下面附上下载链接 如果有帮到你的话请点赞
  • ./nginx: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No

    在CentOS7下配置Nginx 但是一致都在报错 报错信息为 nginx error while loading shared libraries libcrypto so 1 1 cannot open shared object fi
  • Unity3d 离散仿真引擎基础

    Unity3d 游戏 离散仿真引擎基础简答题 1 解释游戏对象 GameObjects 和资源 Assets 的区别与联系 游戏对象 GameObjects 用来表示游戏中具体的角色 道具和场景 它们通过容纳组件 Component 来实现
  • Ubuntu20.04+RTX3090+CUDA11.4+CUDNN8.5.0安装与卸载

    目录 CUDA CUDNN卸载 CUDA CUDNN下载与安装 CUDA CUDNN下载 CUDA CUDNN安装 CUDA CUDNN卸载 CUDA卸载有两种方式 一种是执行CUDA自带的卸载脚本 该脚本位于 usr local cuda
  • 网络驱动->PHY驱动调试

    1 Linux 系统网络协议层架构 网络协议框架图 网络子系统是 linux 操作系统里很重要的一部分 关于这部分有很多的参考资料 这里主要说明一下 phy 芯片在整个子系统里的位置 从这个结构里看到 PHY 驱动的功能处于链路层 以太网物
  • Python实现并发编程

    利用python实现并发编程的方法有 1 多线程 2 多进程 3 多线程 多进程 面试题 进程和线程的区别和联系 进程 操作系统分配内存的基本单位 一个进程可以包含一个或多个线程 线程 操作系统分配CPU的基本单位 并发编程 concurr
  • 我的梦想指引前行与追寻梦想之路

    在毕业季来临之际 我想向即将踏入职场的各位同学们致以真诚的祝福和鼓励 在这个毕业季的到来 让我们满怀梦想和热情 准备好迈出职场的第一步 追逐成功的道路 不断成长和拓展自己的辉煌人生 在大学期间 我有幸参与了一项关于人工智能领域的研究项目 这
  • EF Core CodeFirst 添加表字段表述

    1 通过Fluent API 来添加描述 使用HasComment实现 protected override void OnModelCreating ModelBuilder modelBuilder modelBuilder Entit
  • html视频怎么改大小,对视频大小、比例进行修改

    很多人在刚开始制作视频的时候会问 怎么修改高宽比 怎么做全屏视频 为什么我输出的视频有黑边 我们今天就来把这些问题一并解决了 首先来了解问题的原因 问 为什么输出的视频有黑边 答 当剪辑的视频比例与你所选的项目比例不一致 软件会自动填充黑边
  • 【数学】三角函数及部分微积分函数图象整理

    三角函数及部分微积分函数图象整理 1 三角函数 1 1 cosx secx 1 2 sinx cscx 1 3 tanx cotx 1 4 s e c
  • Easyx简单使用

    创建窗口大小为 initgraph 640 长 480 宽 showconsole 显示控制台 关闭窗口closegraph 绘图函数 例 画圆 radius半径 circle 无填充 fillcircle 有边框填充 solidcircl
  • Study Note:CSIN3 Chapter 2: C# Language Basic

    I should familiar with this chapter If not I should hit the wall 2 1 A First C Program I m very glad to see the first C