Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Simple C# question..

Options
  • 16-11-2004 6:32pm
    #1
    Registered Users Posts: 43,907 ✭✭✭✭


    Pretty standard question but after 2 years of learning Visual Basic, doing simple things is a lot more tricky in C#.

    I've 2 forms - NameScreen and Table.

    On the Form_Load of Table, i simply want to get the value that was entered into a TextBox on the NameScreen form.

    I've made a the following method to get it from the NameScreen class.
    string playerName;
    playerName = txtPName.Text;

    public string getPlayerName()
    {
    return playerName;
    }

    How would i access this method from the Form_Load of Table? Would i need to declare the variable as playerName as public also? Any help is much appreciated.


Comments

  • Closed Accounts Posts: 35 Ivan Dunaev


    Your forms are variables, instances of classes. You can get access to a method of a variable by having the reference to it.


Advertisement