Results 1 to 10 of 10

Thread: [RESOLVED] by value and by ref question related to passing forms

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046

    Resolved [RESOLVED] by value and by ref question related to passing forms

    I dont understand something. If C# passes by value as the default then why does the text on the startup Form1 change when the following code is executed?

    private Form1 frmMain;
    public Form2(Form1 f)
    {
    InitializeComponent();
    frmMain = f;
    frmMain.Text = "Hello";
    }

    I would have thought that a new Form1 named f would be created and that the text change would occur on that new Form1 named f and not on the Form1 that was shown at startup. What am I misunderstanding? ... or are forms passed by reference? ...
    Last edited by Muddy; Aug 8th, 2006 at 01:05 PM. Reason: resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width