今天看一篇文章讲述怎么在net环境下使用com组件中的IL修改的代码中看到了
Marshal([+1]) 这样一个东东,查了不少资料,但是仍然一无所获,请问这个东东做什么用的?其中的“+1”是指示什么?这个数字到底指向什么?
引用原文:
.method public hidebysig newslot virtual abstract
instance void MyNextLongs([in] int32 nReq,
// Replace this: [out] int32& rgelt,
// With this:
[out] int32[] marshal([ + 1]) rgelt,
[out] int32& pnFetched) runtime managed internalcall
就是 阵列的意思
MICROSOFT提交给标准化组织ECMA的规范
可以参考
ECMA-334 --定义了C#编程语言的语法和语义
ECMA-335--定义了许多.NET平台的细节,统称CIL.
[Example:
.method int32 M1( int32 marshal(int32), bool[] marshal(bool[5]) )
Method M1 takes two arguments: an int32, and an array of 5 bools.
.method int32 M2( int32 marshal(int32), bool[] marshal(bool[+1]) )
Method M2 takes two arguments: an int32, and an array of bools: the number of elements in that array is
given by the value of the first parameter.
.method int32 M3( int32 marshal(int32), bool[] marshal(bool[7+1]) )
Method M3 takes two arguments: an int32, and an array of bools: the number of elements in that array is
given as 7 plus the value of the first parameter. end example]