Thread: out variable

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    out variable

    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;
            }
        }

    thanks in advance,
    George

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Great. What is the question ?
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 12:07 PM
  2. Use of variable
    By alice in forum C Programming
    Replies: 8
    Last Post: 06-05-2004, 07:32 AM
  3. Replies: 2
    Last Post: 04-12-2004, 01:37 AM
  4. write Variable and open Variable and get Information
    By cyberbjorn in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2004, 01:30 AM
  5. Variable question I can't find answer to
    By joelmon in forum C++ Programming
    Replies: 3
    Last Post: 02-12-2002, 04:11 AM