https://blog.youkuaiyun.com/susan19890313/article/details/6949685
https://cloud.tencent.com/developer/article/1335491
https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.opcodes?redirectedfrom=MSDN&view=netframework-4.8#fields
IL指令链接
第一种使用方式:
找到ildasm.exe工具:


打开要看的exe文件:


Ldloc——Loads the local variable at a specific index onto the evaluation stack.
Stloc——Pops the current value from the top of the evaluation stack and stores it in a the local variable list at a specified index.
st——store,loc——local

左边Student是class
右边Student是struct


class Student //如果是struct,则为上面的那个图
{
public int a;
}
class Program
{
static void Main(string[] args)
{
Student s = new Student();
List<Student> list = new List<Student>();
list.Add(s);
Console.ReadKey();
}
}
本文深入探讨了IL(中间语言)指令在.NET框架中的应用,详细解析了Ldloc与Stloc指令的功能,即从局部变量列表加载变量到评估堆栈以及从评估堆栈顶部弹出当前值并将其存储在指定索引的局部变量列表中。同时,通过对比class与struct在内存中的表现形式,阐述了它们在.NET内存管理上的区别。
1850

被折叠的 条评论
为什么被折叠?



