ref pointer parameter
using System;
public class Starter {
public unsafe static void Main() {
int val = 5;
int* pA = &val;
Console.WriteLine("Original: {0}", (int)pA);
MethodA(pA);
Console.WriteLine("MethodA: {0}", (int)pA);
MethodB(ref pA);
Console.WriteLine("MethodB: {0}", (int)pA);
}
public unsafe static void MethodA(int* pArg) {
++pArg;
}
public unsafe static void MethodB(ref int* pArg) {
++pArg;
}
}
Related examples in the same category