out variable

This is a discussion on out variable within the C# Programming forums, part of the General Programming Boards category; Hello everyone, Here is my test program. I want to confirm that when we pass an out variable into a ...

  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,139
    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, 08:32 AM
  3. Replies: 2
    Last Post: 04-12-2004, 02:37 AM
  4. write Variable and open Variable and get Information
    By cyberbjorn in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2004, 02: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21