标签:
第一章



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: nop IL_0001: ldstr "hellowlz" IL_0006: stloc.0 IL_0007: ldstr "hello" IL_000c: stloc.1 IL_000d: ldloc.1 IL_000e: ldstr "wlz" IL_0013: call string[mscorlib]System.String::Concat(string,string) IL_0018: stloc.1 IL_0019: ldstr "hello" IL_001e: newobj instance void[mscorlib]System.Text.StringBuilder::.ctor(string) IL_0023: stloc.2 IL_0024: ldloc.2 IL_0025: ldstr "wlz" IL_002a: callvirt instance class[mscorlib]System.Text.StringBuilder[mscorlib]System.Text.StringBuilder::Append(string) IL_002f: pop IL_0030: ldstr "hello" IL_0035: stloc.3 IL_0036: ldloc.3 IL_0037: ldstr "wlz" IL_003c: call string[mscorlib]System.String::Concat(string,string) IL_0041: pop IL_0042: ldloc.0 IL_0043: call void[mscorlib]System.Console::Write(string) IL_0048: nop IL_0049: ret}// end of method Program::Main.method public hidebysig specialname rtspecialname instance void.ctor () cil managed {// Method begins at RVA 0x20a6// Code size 7 (0x7).maxstack 8 IL_0000: ldarg.0 IL_0001: call instance void[mscorlib]System.Object::.ctor() IL_0006: ret}// end of method Program::.ctor}// end of class testDemo.Programvar 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 numint bigNum =int.MaxValue;//2147483647int result = bigNum +1;Console.WriteLine(result);//result的值是-2147483648.locals init ([0]int32 bigNum,[1]int32 result) IL_0000: nop IL_0001: ldc.i4 2147483647 IL_0006: stloc.0 IL_0007: ldloc.0 IL_0008: ldc.i4.1 IL_0009: add IL_000a: stloc.1 IL_000b: ldloc.1 checked{int bigNum =int.MaxValue-1;int result = bigNum +1;} .locals init ([0]int32 bigNum,[1]int32 result) IL_0000: nop IL_0001: nop IL_0002: ldc.i4 2147483646 IL_0007: stloc.0 IL_0008: ldloc.0 IL_0009: ldc.i4.1 IL_000a: add.ovf IL_000b: stloc.1 IL_000c: ldloc.1 string text ="9.11E-31";//Parsefloat parseFloat =float.Parse(text);float tryParseFloat;//TryParse bool 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: nop IL_0001: nop IL_0002: ldstr "9.11E-31" IL_0007: stloc.0 IL_0008: ldloc.0 IL_0009: call float32[mscorlib]System.Single::Parse(string) IL_000e: stloc.1//将得到的值出栈(不是入栈) IL_000f: ldloc.0 IL_0010: ldloca.s tryParseFloat IL_0012: call bool [mscorlib]System.Single::TryParse(string,float32&) IL_0017: stloc.3 IL_0018: ldloca.s tryParseFloat IL_001a: call instance string[mscorlib]System.Single::ToString() IL_001f: stloc.s floatToString IL_0021: ldloc.1 IL_0022: call string[mscorlib]System.Convert::ToString(float32) IL_0027: stloc.s floatConvertToString IL_0029: ldloc.1 IL_002a: call void[mscorlib]System.Console::WriteLine(float32) IL_002f: nop IL_0030: ldloc.3 IL_0031: ldc.i4.0 IL_0032: ceq IL_0034: stloc.s CS$4$0000 IL_0036: ldloc.s CS$4$0000 IL_0038: brtrue.s IL_0043string[] 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
标签:
原文地址:http://www.cnblogs.com/wlzcool/p/4378004.html