static void Main(string[] args) { int i = 1; InOutRef.In(i); //passed by value (in only) Debug.Assert(i == 1); InOutRef.Ref(ref i); //passed by ref (in or out) Debug.Assert(i == 200); InOutRef.Out(out i); //passed by as out ref (out only) Debug.Assert(i == 300); }
static void Main(string[] args) { int i = 1; InOutRef.In(i); //reference doesnt change like java Debug.Assert(i == 1); InOutRef.Ref(ref i); //reference changes like vb.net ref Debug.Assert(i == 200); InOutRef.Out(out i); //must be reassigned before it leaves Debug.Assert(i == 300); }