Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Simple C# question..

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


    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