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设计模式>,开始读书之旅啦. 我 ...
随机推荐
- Asp.net Identity 2.0 作弊条
Moving ASP.NET Identity model to class library http://stackoverflow.com/questions/23446919/moving-as ...
- python数据结构-列表-建立/索引/反转
- java微信接口之五—消息分组群发
一.微信消息分组群发接口简介 1.请求:该请求是使用post提交地址为: https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_t ...
- 第一次配置Android环境
配置Android环境,相信很多人都做过,而且网上的资料也一大堆,我就来分享一下我配置Android的心得吧! 第一步:下载好需要的文件:Android SDK.JDK.Eclipse.ADT ps: ...
- mysql中count(),group by使用
count()统计表中或数组中记录 count(*)返回检索行的数目,且不论其值中是否包含NULL count(column_name)返回的是对列中column_name不为NULL的行的统计 例如 ...
- Reading WebSites
oracle http://www.eygle.com/archives/2006/02/the_sun_repays_industriously.html 蕃茄土豆: https://pomotod ...
- CentOS 6.5部署安装Memcached
1. Yum安装Memcache 查找memcached yum search memcached 该命令可以查询yum库中有关memcached的安装包信息,以下是搜寻结果截图: 安装 memc ...
- 用pygame学习初级python(一) 15.4.19
最近有计划要学一下python,主要是要用flask.django一些框架进行后端的学习工作,但是在web应用之前希望进行一些基础的项目进行一些语法的练习,熟悉一下写法, 这个时候我就想先做几个小游戏 ...
- Elastic search入门
首先是下载elasticsearch https://www.elastic.co/downloads,解压: 然后下载了中文分析器ik,github上搜索elasticsearch-ik就能找到,h ...
- js/jquery判断浏览器的方法总结
JS获取浏览器信息浏览器代码名称:navigator.appCodeName浏览器名称:navigator.appName浏览器版本号:navigator.appVersion对Java的支持:nav ...