Passing value types by reference : Parameter Reference « Language Basics « C# / CSharp Tutorial






using System;
class RefExample2
{
    static void Method(ref string s)
    {
        s = "changed";
    }
    static void Main()
    {
        string str = "original";
        Method(ref str);
        Console.WriteLine(str);
    }
}








1.13.Parameter Reference
1.13.1.Pass references to methods
1.13.2.Objects are passed by reference.
1.13.3.Use ref to pass an int value type by reference
1.13.4.Passing value types by reference