Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Simple C# question..

  • 16-11-2004 06:32PM
    #1
    Registered Users, Registered Users 2 Posts: 45,082 ✭✭✭✭


    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