C#本质论读书笔记:第一章 C#概述|第二章 数据类型
第一章



namespace testDemo{classProgram{staticvoidMain(string[] args){string a ="hello"+"wlz";string b ="hello";b +="wlz";StringBuilder c =newStringBuilder("hello");c.Append("wlz");string d ="hello";string.Concat(d,"wlz");Console.Write(a);}}}
.classprivateauto ansi beforefieldinit testDemo.Programextends[mscorlib]System.Object{// Methods.method private hidebysig staticvoidMain(string[] args) cil managed{// Method begins at RVA 0x2050// Code size 74 (0x4a).maxstack 2.entrypoint.locals init ([0]string a,[1]string b,[2]class[mscorlib]System.Text.StringBuilder c,[3]string d)IL_0000: nopIL_0001: ldstr "hellowlz"IL_0006: stloc.0IL_0007: ldstr "hello"IL_000c: stloc.1IL_000d: ldloc.1IL_000e: ldstr "wlz"IL_0013: call string[mscorlib]System.String::Concat(string,string)IL_0018: stloc.1IL_0019: ldstr "hello"IL_001e: newobj instance void[mscorlib]System.Text.StringBuilder::.ctor(string)IL_0023: stloc.2IL_0024: ldloc.2IL_0025: ldstr "wlz"IL_002a: callvirt instance class[mscorlib]System.Text.StringBuilder[mscorlib]System.Text.StringBuilder::Append(string)IL_002f: popIL_0030: ldstr "hello"IL_0035: stloc.3IL_0036: ldloc.3IL_0037: ldstr "wlz"IL_003c: call string[mscorlib]System.String::Concat(string,string)IL_0041: popIL_0042: ldloc.0IL_0043: call void[mscorlib]System.Console::Write(string)IL_0048: nopIL_0049: ret}// end of method Program::Main.method public hidebysig specialname rtspecialnameinstance void.ctor () cil managed{// Method begins at RVA 0x20a6// Code size 7 (0x7).maxstack 8IL_0000: ldarg.0IL_0001: call instance void[mscorlib]System.Object::.ctor()IL_0006: ret}// end of method Program::.ctor}// end of class testDemo.Program
var person =new{ name="wlz",phone="12346"};
[4]class'<>f__AnonymousType0`2'<string,string> person,IL_004f: ldstr "wlz"IL_0054: ldstr "12346"IL_0059: newobj instance voidclass'<>f__AnonymousType0`2'<string,string>::.ctor(!0,!1)
int? nullNum =null;int num =42;
[5] valuetype [mscorlib]System.Nullable`1<int32> nullNum,[6]int32 numIL_0060: ldloca.s nullNumIL_0062: initobj valuetype [mscorlib]System.Nullable`1<int32>IL_0068: ldc.i4.s 42IL_006a: stloc.s num
int bigNum =int.MaxValue;//2147483647int result = bigNum +1;Console.WriteLine(result);//result的值是-2147483648
.locals init ([0]int32 bigNum,[1]int32 result)IL_0000: nopIL_0001: ldc.i4 2147483647IL_0006: stloc.0IL_0007: ldloc.0IL_0008: ldc.i4.1IL_0009: addIL_000a: stloc.1IL_000b: ldloc.1
checked{int bigNum =int.MaxValue-1;int result = bigNum +1;}
.locals init ([0]int32 bigNum,[1]int32 result)IL_0000: nopIL_0001: nopIL_0002: ldc.i4 2147483646IL_0007: stloc.0IL_0008: ldloc.0IL_0009: ldc.i4.1IL_000a: add.ovfIL_000b: stloc.1IL_000c: ldloc.1
string text ="9.11E-31";//Parsefloat parseFloat =float.Parse(text);float tryParseFloat;//TryParsebool successParseFloat =float.TryParse(text,out tryParseFloat);//ToStringstring floatToString=tryParseFloat.ToString();string floatConvertToString=Convert.ToString(parseFloat);Console.WriteLine(parseFloat);
.locals init ([0]string text,[1]float32 parseFloat,[2]float32 tryParseFloat,[3] bool successParseFloat,[4]string floatToString,[5]string floatConvertToString,[6] bool CS$4$0000)IL_0000: nopIL_0001: nopIL_0002: ldstr "9.11E-31"IL_0007: stloc.0IL_0008: ldloc.0IL_0009: call float32[mscorlib]System.Single::Parse(string)IL_000e: stloc.1//将得到的值出栈(不是入栈)IL_000f: ldloc.0IL_0010: ldloca.s tryParseFloatIL_0012: call bool [mscorlib]System.Single::TryParse(string,float32&)IL_0017: stloc.3IL_0018: ldloca.s tryParseFloatIL_001a: call instance string[mscorlib]System.Single::ToString()IL_001f: stloc.s floatToStringIL_0021: ldloc.1IL_0022: call string[mscorlib]System.Convert::ToString(float32)IL_0027: stloc.s floatConvertToStringIL_0029: ldloc.1IL_002a: call void[mscorlib]System.Console::WriteLine(float32)IL_002f: nopIL_0030: ldloc.3IL_0031: ldc.i4.0IL_0032: ceqIL_0034: stloc.s CS$4$0000IL_0036: ldloc.s CS$4$0000IL_0038: brtrue.s IL_0043
string[] languages;
string[] languages={"C#","Java"};
string[] languages;languages=newstring[]{"C#","Java"};
string[] lanua =newstring[]{"C#","Java"};

int[,] table =newint[3,3];
int[][] crosstable ={newint[]{1,0,2},newint[]{3,2},newint[]{1},newint[]{}};
crosstable[2][2]=1;
bool[,,] cells =new bool[2,3,4];System.Console.WriteLine(cells.GetLength(2));//获取第三个维度,得到4System.Console.WriteLine(cells.Length);//24

C#本质论读书笔记:第一章 C#概述|第二章 数据类型的更多相关文章
- 【读书笔记】C#高级编程 第二章 核心C#
(一)第一个C#程序 创建一个控制台应用程序,然后输入代码,输入完毕后点击F5 Console.WriteLine();这条语句的意思:把括号内的内容输出到界面上: Console.ReadKey() ...
- 《Linux内核设计与实现》读书笔记——第一、 二章
<Linux内核设计与实现>读书笔记--第一. 二章 标签(空格分隔): 20135321余佳源 第一章 Linux内核简介 1.Unix内核特点 十分简洁:仅提供几百个系统调用并且有明确 ...
- 《javascript权威指南》读书笔记——第一篇
<javascript权威指南>读书笔记——第一篇 金刚 javascript js javascript权威指南 由于最近想系统学习下javascript,所以开始在kindle上看这本 ...
- 《C#从现象到本质》读书笔记(九)第11章C#的数据结构
<C#从现象到本质>读书笔记(九)第11章C#的数据结构 C#中的数据结构可以分为两类:非泛型数据结构和泛型数据结构. 通常迭代器接口需要实现的方法有:1)hasNext,是否还有下一个元 ...
- 《C#从现象到本质》读书笔记(八)第10章反射
<C#从现象到本质>读书笔记(八)第10章反射 个人感觉,反射其实就是为了能够在程序运行期间动态的加载一个外部的DLL集合,然后通过某种办法找到这个DLL集合中的某个空间下的某个类的某个成 ...
- 《C#从现象到本质》读书笔记(七)第9章 泛型
<C#从现象到本质>读书笔记(七)第9章 泛型 泛型的三大好处:类型安全,增强性能(避免装箱和拆箱),代码复用. 泛型方法是传入的参数至少有一个类型为T(尚未制定的类型,根据微软的命名规则 ...
- 《C#从现象到本质》读书笔记(五)第5章字符串第6章垃圾回收第7章异常与异常处理
<C#从现象到本质>读书笔记(五)第5章字符串 字符串是引用类型,但如果在某方法中,将字符串传入另一方法,在另一方法内部修改,执行完之后,字符串的只并不会改变,而引用类型无论是按值传递还是 ...
- ASM学习笔记--ASM 4 user guide 第二章要点翻译总结
参考:ASM 4 user guide 第一部分 core API 第二章 类 2.1.1概观 编译后的类包括: l 一个描述部分:包括修饰语(比如public或private).名字.父类.接口 ...
- JS高程读书笔记-第一、二章-内附在线思维导图和quizlet卡片
之前在kindle上买了高程,今天又到了纸质的<JavaScript语言精粹>,<高性能JavaScript>,<JavaScipt设计模式>,开始读书之旅啦. 我 ...
随机推荐
- 一个人的Scrum之准备工作
在2012年里,我想自己一人去实践一下Scrum,所以才有了这么一个开篇. 最近看了<轻松的Scrum之旅>这本书,感觉对我非常有益.书中像讲述故事一样描述了在执行Scrum过程中的点点滴 ...
- 未能找到元数据文件“引用的DLL的路径”
使用VS的时候 偶尔会出现错误 [未能找到元数据文件“引用的DLL的路径”] 但是实际上项目中这些DLL都是做了引用的,甚至你前一天打开还是好好的,睡一觉起来 不知道什么原因 就酱紫了 原因:不详 ...
- 通过正则获取URL中的参数
闲着无聊用正则做了一个获取URL参数的小算法^_^ function getParam(name) { var objs = window.location.search.match("(\ ...
- python文件和元组
python文件操作 相较于java,Python里的文件操作简单了很多 python 获取当前文件所在的文件夹: os.path.dirname(__file__) 写了一个工具类,用来在当前文件夹 ...
- CentOS6.5上golang环境配置
CentOS6.5上golang环境配置 一.下载和解压go环境包 >>cd /usr/local/src/ >>wget -c http://golangtc.com/sta ...
- [转]Excel - How to lock cell without using macros if possible
本文转自:http://stackoverflow.com/questions/11953214/excel-how-to-lock-cell-without-using-macros-if-poss ...
- 【转载】PMC/PEC Boundary Conditions and Plane Wave Simulation
原文链接 PMC/PEC Boundary Conditions and Plane Wave Simulation (FDTD) OptiFDTD now has options to use Pe ...
- 迭代加深搜索 POJ 1129 Channel Allocation
POJ 1129 Channel Allocation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 14191 Acc ...
- 怎么通过js获取上传的图片信息(临时保存路径,名称,大小)然后通过ajax传递给后端?
今天在论坛上看到这样一个问题,有必要编辑搜集下. 问题描述:怎么通过js获取上传的图片信息(临时保存路径,名称,大小)然后通过ajax传递给后端 题主用jquery接收 <input name= ...
- tomcat7 - 烫手山芋之热部署
tomcat7部署,项目发布有很多种方式 1. 增量发布,把修改过得那些文件手动上传至tomcat,*.class *.xml 等等,这样的缺点非常大,需要断开tomcat,记住那些你修改过得文件,很 ...