yield return Il代码讲解
2021/9/22 6:10:48
本文主要是介绍yield return Il代码讲解,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
.class nested private auto ansi sealed beforefieldinit '<GetEnumerator>d__12' extends [System.Runtime]System.Object implements class [System.Runtime]System.Collections.Generic.IEnumerator`1<object>, [System.Runtime]System.Collections.IEnumerator, [System.Runtime]System.IDisposable //这个位置相当于以上等于 private class sealed <GetEnumerator>d__12:object,IEnumerator,IEnumerator,IDisposable // nested :嵌套 //implements :实现接口 //extends:是继承父类,只要那个类不是声明为final或者那个类定义为abstract的就能继承, { .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) // Fields 字段 .field private int32 '<>1__state' .field private object '<>2__current' .field public class School.ClassOfStudent '<>4__this' .field private int32 '<index>5__1' // Methods // .method public hidebysig specialname rtspecialname instance void .ctor ( int32 '<>1__state' ) cil managed //cil managed:托管代码 { .custom instance void [System.Runtime]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) // Method begins at RVA 0x2369 // Code size 15 (0xf) .maxstack 8 // { IL_0000: ldarg.0 // (no C# code) IL_0001: call instance void [System.Runtime]System.Object::.ctor() // this.<>1__state = <>1__state; IL_0006: nop IL_0007: ldarg.0 IL_0008: ldarg.1 IL_0009: stfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<>1__state' // } IL_000e: ret } // end of method '<GetEnumerator>d__12'::.ctor .method private final hidebysig newslot virtual instance void System.IDisposable.Dispose () cil managed { .custom instance void [System.Runtime]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) .override method instance void [System.Runtime]System.IDisposable::Dispose() // Method begins at RVA 0x2379 // Code size 1 (0x1) .maxstack 8 // } IL_0000: ret } // end of method '<GetEnumerator>d__12'::System.IDisposable.Dispose .method private final hidebysig newslot virtual instance bool MoveNext () cil managed { .override method instance bool [System.Runtime]System.Collections.IEnumerator::MoveNext() // Method begins at RVA 0x237c // Code size 133 (0x85) .maxstack 3 .locals init ( [0] int32, [1] int32, [2] bool ) // switch (<>1__state) IL_0000: ldarg.0 IL_0001: ldfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<>1__state' IL_0006: stloc.0 // (no C# code) IL_0007: ldloc.0 IL_0008: brfalse.s IL_0012 IL_000a: br.s IL_000c IL_000c: ldloc.0 IL_000d: ldc.i4.1 IL_000e: beq.s IL_0014 IL_0010: br.s IL_0016 IL_0012: br.s IL_0018 // return false; IL_0014: br.s IL_004f IL_0016: ldc.i4.0 IL_0017: ret // <>1__state = -1; IL_0018: ldarg.0 IL_0019: ldc.i4.m1 IL_001a: stfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<>1__state' // <index>5__1 = 0; IL_001f: nop IL_0020: ldarg.0 IL_0021: ldc.i4.0 IL_0022: stfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<index>5__1' // break; IL_0027: br.s IL_0067 // <>2__current = <>4__this.students[<index>5__1]; IL_0029: nop IL_002a: ldarg.0 IL_002b: ldarg.0 IL_002c: ldfld class School.ClassOfStudent School.ClassOfStudent/'<GetEnumerator>d__12'::'<>4__this' IL_0031: ldfld class [System.Collections]System.Collections.Generic.List`1<class School.Student> School.ClassOfStudent::students IL_0036: ldarg.0 IL_0037: ldfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<index>5__1' IL_003c: callvirt instance !0 class [System.Collections]System.Collections.Generic.List`1<class School.Student>::get_Item(int32) IL_0041: stfld object School.ClassOfStudent/'<GetEnumerator>d__12'::'<>2__current' // <>1__state = 1; IL_0046: ldarg.0 IL_0047: ldc.i4.1 IL_0048: stfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<>1__state' // return true; IL_004d: ldc.i4.1 IL_004e: ret // <>1__state = -1; IL_004f: ldarg.0 IL_0050: ldc.i4.m1 IL_0051: stfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<>1__state' // <index>5__1++; IL_0056: nop IL_0057: ldarg.0 IL_0058: ldfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<index>5__1' IL_005d: stloc.1 // if (<index>5__1 < <>4__this.students.Count) IL_005e: ldarg.0 IL_005f: ldloc.1 IL_0060: ldc.i4.1 IL_0061: add IL_0062: stfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<index>5__1' IL_0067: ldarg.0 IL_0068: ldfld int32 School.ClassOfStudent/'<GetEnumerator>d__12'::'<index>5__1' IL_006d: ldarg.0 IL_006e: ldfld class School.ClassOfStudent School.ClassOfStudent/'<GetEnumerator>d__12'::'<>4__this' IL_0073: ldfld class [System.Collections]System.Collections.Generic.List`1<class School.Student> School.ClassOfStudent::students IL_0078: callvirt instance int32 class [System.Collections]System.Collections.Generic.List`1<class School.Student>::get_Count() IL_007d: clt IL_007f: stloc.2 IL_0080: ldloc.2 IL_0081: brtrue.s IL_0029 // return false; IL_0083: ldc.i4.0 IL_0084: ret } // end of method '<GetEnumerator>d__12'::MoveNext .method private final hidebysig specialname newslot virtual instance object 'System.Collections.Generic.IEnumerator<System.Object>.get_Current' () cil managed { .custom instance void [System.Runtime]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) .override method instance !0 class [System.Runtime]System.Collections.Generic.IEnumerator`1<object>::get_Current() // Method begins at RVA 0x240d // Code size 7 (0x7) .maxstack 8 // return <>2__current; IL_0000: ldarg.0 IL_0001: ldfld object School.ClassOfStudent/'<GetEnumerator>d__12'::'<>2__current' IL_0006: ret } // end of method '<GetEnumerator>d__12'::'System.Collections.Generic.IEnumerator<System.Object>.get_Current' .method private final hidebysig newslot virtual instance void System.Collections.IEnumerator.Reset () cil managed { .custom instance void [System.Runtime]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) .override method instance void [System.Runtime]System.Collections.IEnumerator::Reset() // Method begins at RVA 0x2415 // Code size 6 (0x6) .maxstack 8 // throw new NotSupportedException(); IL_0000: newobj instance void [System.Runtime]System.NotSupportedException::.ctor() IL_0005: throw } // end of method '<GetEnumerator>d__12'::System.Collections.IEnumerator.Reset .method private final hidebysig specialname newslot virtual instance object System.Collections.IEnumerator.get_Current () cil managed { .custom instance void [System.Runtime]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 ) .override method instance object [System.Runtime]System.Collections.IEnumerator::get_Current() // Method begins at RVA 0x241c // Code size 7 (0x7) .maxstack 8 // return <>2__current; IL_0000: ldarg.0 IL_0001: ldfld object School.ClassOfStudent/'<GetEnumerator>d__12'::'<>2__current' IL_0006: ret } // end of method '<GetEnumerator>d__12'::System.Collections.IEnumerator.get_Current // Properties .property instance object 'System.Collections.Generic.IEnumerator<System.Object>.Current'() { .get instance object School.ClassOfStudent/'<GetEnumerator>d__12'::'System.Collections.Generic.IEnumerator<System.Object>.get_Current'() } .property instance object System.Collections.IEnumerator.Current() { .get instance object School.ClassOfStudent/'<GetEnumerator>d__12'::System.Collections.IEnumerator.get_Current() } } // end of class <GetEnumerator>d__12
这篇关于yield return Il代码讲解的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-01后台管理开发学习:新手入门指南
- 2024-11-01后台管理系统开发学习:新手入门教程
- 2024-11-01后台开发学习:从入门到实践的简单教程
- 2024-11-01后台综合解决方案学习:从入门到初级实战教程
- 2024-11-01接口模块封装学习入门教程
- 2024-11-01请求动作封装学习:新手入门教程
- 2024-11-01登录鉴权入门:新手必读指南
- 2024-11-01动态面包屑入门:轻松掌握导航设计技巧
- 2024-11-01动态权限入门:新手必读指南
- 2024-11-01动态主题处理入门:新手必读指南