Fixing Managed Data in Memory : IntPtr « unsafe « C# / CSharp Tutorial






using System;
   
public class MyClass
{
    public unsafe static void Main()
    {
        int ArrayIndex;
        int [] IntegerArray;
   
        IntegerArray = new int [5];
        fixed(int * IntegerPointer = IntegerArray)
        {
            for(ArrayIndex = 0; ArrayIndex < 5; ArrayIndex++)
                IntegerPointer[ArrayIndex] = ArrayIndex;
        }
        for(ArrayIndex = 0; ArrayIndex < 5; ArrayIndex++)
            Console.WriteLine(IntegerArray[ArrayIndex]);
    }
}








36.2.IntPtr
36.2.1.IntPtr.Zero
36.2.2.Fixing Managed Data in Memory