# 純C ++/CLI的MSIL

/clr:pure switch generates pure MSIL but it is not verifible. Native array and pointer can be used in this mode. Does that mean that there is a structure in MSIL to hold native arrays and pointers? If yes, I would like to ask how can I code MSIL native array and pointer?

## 最佳答案

Yes, there is a type in CIL to represent unmanaged pointers. They are similar to managed pointers (ref and out in C#, & in CIL), except that GC ignores them and you can do some arithmetic operations on them (those that make sense with pointers).

void Bar(int *a)
{
a[5] = 15;
}


.method private hidebysig instance void Bar(int32* a) cil managed
{
.maxstack 2
L_0000: ldarg.1     //load the value of a pointer to the stack
L_0001: ldc.i4.s 20 //load the number 20 (= 4 * 5) to the stack