1

I've disassmebled the following C++/CLI code in ildasm:

Managed(char * const a)
{

}

and the disassembled IL looks like this:

.method public hidebysig specialname rtspecialname 
        instance void  .ctor(int8 modopt([mscorlib]System.Runtime.CompilerServices.IsSignUnspecifiedByte)* modopt([mscorlib]System.Runtime.CompilerServices.IsConst) modopt([mscorlib]System.Runtime.CompilerServices.IsConst) a) cil managed

Removing some insignificant parts:

.method public hidebysig specialname rtspecialname 
        instance void .ctor(int8* modopt(IsConst) modopt(IsConst) a) cil managed

So while there is only one const in the original code, it is emitted twice in the IL. Why is that so?

IS4
  • 11,945
  • 2
  • 47
  • 86
  • FYI, if I create a method with just one `modopt(IsConst)`, it seems to behave the same as a method with two of them, when referenced from C++/CLI. – svick Dec 08 '14 at 18:01

0 Answers0