0

I've created the following class:

class Player
{
    public string Name { get; set; }
    public string Symbol { get; set; }
    
    public Player(string name, string symbol)
    {
        Name = name;
        Symbol = symbol;
    }
}

and in my first Form (FormStart) I'm creating an instance:

Player player1 = new Player(textBoxPlayer1.Text, labelChar1.Text);
Player player2 = new Player(textBoxPlayer2.Text, labelChar2.Text);

Now I want to set the fields of player1 and player2 in labels in another Form. Any ideas how to make it?

wohlstad
  • 12,661
  • 10
  • 26
  • 39
zaraboy
  • 11
  • 3
  • 2
    Pretty sure you need to pass them to the page when you open it, I don't think you can reference another open page directly. Or, use cookies. – Johnny Bones Jul 25 '22 at 12:26
  • You will need some sort mechanism to pass the Player instance between the forms! – phuzi Jul 25 '22 at 12:26
  • You should [read this](http://jmcilhinney.blogspot.com/2012/04/managing-data-among-multiple-forms-part.html). – user18387401 Jul 25 '22 at 12:27
  • If this was about Windows Forms, you have your answer. If it was about an Internet form, you'll have to ask again and specify that. Looks like Heinzi made the assumption and closed this one already. – Johnny Bones Jul 25 '22 at 12:33

0 Answers0