问题描述
当我使用params关键字作为参数时,我在IL中找到了这一行.我从中了解到的是调用了ParamArrayAttribute类的构造函数,但我不理解01 00 00 00的含义.
When I used the params keyword for a parameter I found this line in the IL. What I understood from this is that a constructor of the ParamArrayAttribute class is called but I didn't understand what 01 00 00 00 means.
.custom instance void [mscorlib]System.ParamArrayAttribute::.ctor() = (
01 00 00 00
)
推荐答案
Custom attributes are declared using the directive .custom, followed by the method
declaration for a type constructor, optionally followed by a Bytes in parentheses:
CustomDecl ::=
Ctor [ ‘=’ ‘(’ Bytes ‘)’ ]
Bytes
段的格式在II.23.3节中定义:
The format of the Bytes
segment is defined in section II.23.3:
CustomAttrib starts with a Prolog – an unsigned int16, with value 0x0001.
...
Next is a description of the optional "named" fields and properties. This starts with
NumNamed – an unsigned int16 giving the number of "named" properties or fields that
follow. Note that NumNamed shall always be present. A value of zero indicates that there
are no "named" properties or fields to follow (and of course, in this case, the
CustomAttrib shall end immediately after NumNamed).
VI.B.3.节中提供了各种自定义属性的示例.
Examples of various custom attributes are provided in section VI.B.3.
对于ParamArrayAttribute
,前两个字节(01 00
)是Prolog
(采用小尾数格式),后两个字节(00 00
)是NumNamed
(0 =否参数).
In the case of ParamArrayAttribute
, the first two bytes (01 00
) are Prolog
(in little-endian format), and the last two bytes (00 00
) are NumNamed
(0 = no arguments).
这篇关于IL".custom实例void [attribute] =(...)"是什么意思?意思是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!