Use out to mark an object parameter : Function Parameters « Language Basics « C# / C Sharp






Use out to mark an object parameter

 

using System;

class XInt {

    public int iField = 5;
}

class Starter {

    public static void MethodA(out XInt alias) {
        XInt inner = new XInt();
        alias = inner;
    }

    public static void Main() {
        XInt obj;
        MethodA(out obj);
        Console.WriteLine(obj.iField); // 5
    }
}

 








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.Pass valuel by pointer
5.ref pointer parameter
6.Arrays as Function Returns and Parameters
7.Use ref to mark an object parameter
8.Pass integer by reference