Dura Soft
.NET-36
unsafe public static void usePointers(int[] array)
{
fixed(int* ptrArray = array) {
for (int i = 0; i < array.Length; i++)
Console.Write(*(ptrArray + i) + " ");
}
}
…
{ ValTypeX instOfX;
ValTypeX[] myXArray = new ValTypeX[2];
RefTypeY objY = new RefTypeY();
…
unsafe
{
ValTypeX* ptrX = &instOfX;
// No need to use fixed for Value type (on the stack, remember!)
Console.WriteLine(ptrX->val);
fixed(ValTypeX* ptrX2 = myXArray) {
Console.WriteLine(ptrX2->val);
}
fixed(int* pVal = &objY.val) {
Console.WriteLine(*pVal);
}
…
Usage of unsafe