George George

George George

  • NA
  • 778
  • 0

out variable

Jun 11 2008 10:14 PM

Hello everyone,


Here is my test program. I want to confirm that when we pass an out variable into a function, we just pass a reference, no additional copy is made?

[Code]
    class Program
    {
        struct Foo
        {
            public int abc;
        }

        static void Test(out Foo f)
        {
            f.abc = 200;

            return;
        }

        static void Main(string[] args)
        {
            Foo f1;
            f1.abc = 100;
            Test(out f1);

            // output 200
            Console.WriteLine(f1.abc);

            return;
        }
    }
[/Code]


thanks in advance,
George


Answers (2)