vb.net - 什么是反编译的 VB 中的 __PostIncrement(通过 ILSpy)

标签 vb.net cil decompiling ilspy

我只是仔细阅读了 System.Collections.Generic.List(Of T).Add(item As T) 的反编译代码使用 ILSpy,我发现了对 __PostIncrement 的调用.我在 VB 中从未听说过这样的事情,所以我做了一些挖掘并发现:

  1. 在 VB 中,代码是 Me._items(__PostIncrement(Me._size)) = item .
  2. 在 C# 中,代码是 this._items[this._size++] = item;使用该语言的实际后增量运算符
  3. 在 MSIL 中,没有函数调用。它看起来像 C# 后增量一样工作(评论是我的,但我不是 MSIL 专家,所以我可能是错的)。

代码是:

IL_001e: ldarg.0
IL_001f: ldfld !0[] class System.Collections.Generic.List`1<!T>::_items
IL_0024: ldarg.0
IL_0025: dup
IL_0026: ldfld int32 class System.Collections.Generic.List`1<!T>::_size
IL_002b: dup
IL_002c: stloc.0           // store the size pre incrementing
IL_002d: ldc.i4.1
IL_002e: add               // do the increment
IL_002f: stfld int32 class System.Collections.Generic.List`1<!T>::_size
IL_0034: ldloc.0           // reload the stored size to use as index in stelem
IL_0035: ldarg.1
IL_0036: stelem.any !T

这到底是什么 __PostIncrement ?在VB中符号化后自增IL代码是SharpDevelop的发明吗?或者它实际上是我可以在自己的 VB 代码中使用的某种定义?

最佳答案

__PostIncrement 相当于 C# operator++ .这是一种增加(加一)数字的快速方法。不幸的是,根据list of operators in Visual Basic , 没有等价物。

关于vb.net - 什么是反编译的 VB 中的 __PostIncrement(通过 ILSpy),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14109545/

相关文章:

java - 部署具有下降逆向工程保护的跨平台Java桌面应用程序?

c# - 反编译C#时出现"PrivateImplementationDetails"函数

c# - 创建一个从父属性继承的环境属性

cil - 哪些处理器可以运行 CIL

.net - MSIL检查

.net - 修改现有的 .NET 程序集

javascript - 用javascript设置Dropdownlist选定索引?

vb.net - 适用于 .NET 的免费时间表/时间表 GUI 库

vb.net - vb.net 中的 List.ForEach - 让我困惑

java - 从 JAR 恢复代码