Pass valuel by pointer : Function Parameters « Language Basics « C# / C Sharp






Pass valuel by pointer

 
using System;

public class Starter {
    public unsafe static void Main() {
        int val = 5;
        int* pA = &val;
        int* pB;
        pB = MethodA(pA);
        Console.WriteLine("*pA = {0} | *pB = {0}", *pA, *pB);
    }

    public unsafe static int* MethodA(int* pArg) {
        *pArg += 15;
        return pArg;
    }
}

 








Related examples in the same category

1.Reference, output and value parameters.
2.Passing parameters to methods
3.creates instances of a value and a reference type
4.ref pointer parameter
5.Arrays as Function Returns and Parameters
6.Use ref to mark an object parameter
7.Use out to mark an object parameter
8.Pass integer by reference