扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:朱先忠编译 来源:天极开发 2007年11月11日
关键字:
var classes = new List<MyClass> { new MyClass { nameofClass = "Science", studentNames = {"Laura", "George"} }, new MyClass { nameofClass = "Commerce", studentNames = {"Bill", "Hillary"} } }; |
var classes = new List<MyClass>(); var __c1 = new MyClass (); __c1.nameofClass = "Science"; __c1.studentNames.Add("Laura"); __c1.studentNames.Add("George"); classes.Add(__c1); var __c2 = new MyClass(); __c2.nameofClass = "Commerce"; __c2.studentNames.Add("Bill"); __c2.studentNames.Add("Hillary"); classes.Add(__c2); |
.method private hidebysig static void Main(string[] args) cil managed { .entrypoint //代码大小 138 (0x8a) .maxstack 3 .locals init ([0] class [mscorlib]System.Collections.Generic.List`1 <class CollectionInitializer.Program/MyClass> classes, [1] class [mscorlib]System.Collections.Generic.List`1 <class CollectionInitializer.Program/MyClass> '<tampa>f__0', [2] class CollectionInitializer.Program/MyClass '<tampa>f__1', [3] class CollectionInitializer.Program/MyClass '<tampa>f__2') IL_0000: nop IL_0001: nop IL_0002: newobj instance void class [mscorlib]System.Collections. Generic.List`1<class CollectionInitializer. Program/MyClass>::.ctor() IL_0007: stloc.1 IL_0008: ldloc.1 IL_0009: nop IL_000a: newobj instance void CollectionInitializer. Program/MyClass::.ctor() IL_000f: stloc.2 IL_0010: ldloc.2 IL_0011: ldstr "Science" IL_0016: stfld string CollectionInitializer. Program/MyClass::nameofClass IL_001b: nop IL_001c: ldloc.2 IL_001d: ldfld class [mscorlib]System.Collections.Generic.List`1 <string> CollectionInitializer. Program/MyClass::studentNames IL_0022: ldstr "Laura" IL_0027: callvirt instance void class [mscorlib]System. Collections.Generic.List`1<string>::Add(!0) IL_002c: nop IL_002d: ldloc.2 IL_002e: ldfld class [mscorlib]System.Collections.Generic.List`1 <string> CollectionInitializer. Program/MyClass::studentNames IL_0033: ldstr "George" IL_0038: callvirt instance void class [mscorlib]System.Collections. Generic.List`1<string>::Add(!0) IL_003d: nop IL_003e: nop IL_003f: ldloc.2 IL_0040: nop IL_0041: callvirt instance void class [mscorlib]System.Collections. Generic.List`1<class CollectionInitializer. Program/MyClass>::Add(!0) IL_0046: nop IL_0047: ldloc.1 IL_0048: nop IL_0049: newobj instance void CollectionInitializer. Program/MyClass::.ctor() IL_004e: stloc.3 IL_004f: ldloc.3 IL_0050: ldstr "Commerce" IL_0055: stfld string CollectionInitializer. Program/MyClass::nameofClass IL_005a: nop IL_005b: ldloc.3 IL_005c: ldfld class [mscorlib]System.Collections.Generic.List`1 <string> CollectionInitializer. Program/MyClass::studentNames IL_0061: ldstr "Bill" IL_0066: callvirt instance void class [mscorlib]System.Collections. Generic.List`1<string>::Add(!0) IL_006b: nop IL_006c: ldloc.3 IL_006d: ldfld class [mscorlib]System.Collections.Generic.List`1 <string> CollectionInitializer. Program/MyClass::studentNames IL_0072: ldstr "Hillary" IL_0077: callvirt instance void class [mscorlib]System.Collections. Generic.List`1<string>::Add(!0) IL_007c: nop IL_007d: nop IL_007e: ldloc.3 IL_007f: nop IL_0080: callvirt instance void class [mscorlib]System.Collections. Generic.List`1<class CollectionInitializer. Program/MyClass>::Add(!0) IL_0085: nop IL_0086: ldloc.1 IL_0087: nop IL_0088: stloc.0 IL_0089: ret } //Program::Main方法结束 |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者