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设计模式>,开始读书之旅啦. 我 ...
随机推荐
- python yield
http://www.jb51.net/article/15717.htm 这里还不错 只是粗略的知道yield可以用来为一个函数返回值塞数据,比如下面的例子: def addlist(alist) ...
- Effective Java 65 Don't ignore exceptions
Principle An empty catch block defeats the purpose of exceptions, which is to force you to handle ex ...
- 在Web api2 中传递复杂参数的一点心得
这两天在做的一个项目基于webapi2,期间遇到了复杂参数传递的问题.其中刚好看到园友的这篇文章,但是我测试收结果是失败的,还不知道是什么原因.最终经过思考后,找到了一种方法,和大家分享下. 在前端我 ...
- 【故障处理】IMP-00010错误 12C的dmp文件导入11G
[故障处理]IMP-00010错误 12C的dmp文件导入11G 1 BLOG文档结构图 2 前言部分 2.1 导读和注意事项 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其 ...
- 百度地图秘钥ak的获取
今天打开网站的时候出现了这个问题“百度未授权使用地图API, 可能是因为您提供的密钥不是有效的百度开放平台密钥或此密钥未对本应用的百度地图JavasoriptAPI授权.....”经过研究终于知道什么 ...
- 学完STM32开发板,就选4412开发板让你有目标的学习嵌入式开发
600余页用户使用手册 linux实验手册(资料不断更新)100期配套零基础高清视频教程 轻松入门 (资料不断更新)2000人售后认证群 在线支持 售后无忧 源码全开源 原厂技术资料经典学习书籍推荐 ...
- [转]jQuery UI Dialog Modal Popup Yes No Confirm example in ASP.Net
本文转自:http://www.aspsnippets.com/Articles/jQuery-UI-Dialog-Modal-Popup-Yes-No-Confirm-example-in-ASPN ...
- HBase性能调优
因官方Book Performance Tuning部分章节没有按配置项进行索引,不能达到快速查阅的效果.所以我以配置项驱动,重新整理了原文,并补充一些自己的理解,如有错误,欢迎指正. 配置优化 zo ...
- Linux 系统常用命令汇总(二) vi 文本编辑
文本编辑 vi 命令 作用 +文件名 编辑文本文件,若文件不存在同时创建该文件 Ctrl+f 向后翻一页 Ctrl+b 向前翻一页 Ctrl+d 向后翻半页 Ctrl+u 向前翻半页 + 光标移动到下 ...
- 边工作边刷题:70天一遍leetcode: day 84-2
要点:这题是combination的应用,从左向右想比从右向左容易. 因为有结果从小到大的要求,暗示用combintion而不是permutation 其实就是从小到大验证因子,每个因子和其对称因子立 ...