这是代码:
public partial class PlayerChooser : Window
{
public PlayerChooser()
{
InitializeComponent();
textBoxPlayer1Name.Visibility = Visibility.Hidden;
textBoxPlayer2Name.Visibility = Visibility.Hidden;
textBoxPlayer3Name.Visibility = Visibility.Hidden;
textBoxPlayer4Name.Visibility = Visibility.Hidden;
}
public static String player1Name;
public static String player2Name;
public static String player3Name;
public static String player4Name;
...
PlayerChooser.player1Name = textBoxPlayer1Name.Text;
PlayerChooser.player2Name = textBoxPlayer2Name.Text;
TwoPlayers501_new twoPlayers501_new = new TwoPlayers501_new();
twoPlayers501_new.Show();
...
}
发生异常的类和构造函数
public partial class TwoPlayers501_new : Window
{
public TwoPlayers501_new()
{
InitializeComponent();
textBlockPlayer1Name.Text = PlayerChooser.player1Name;
textBlockPlayer2Name.Text = PlayerChooser.player2Name;
}
...
}
提前,这可能是某种微不足道的......
答案 0 :(得分:4)
您是否在某处执行了一个事件处理程序,根据已更改的属性更改其中一个属性?
简短版本:此处没有足够的信息来调试您的问题。
建议:调试程序,当你遇到stackoverflowexception时,请查看callstack。我怀疑有一种方法或一系列方法在你的堆栈中无限循环。
答案 1 :(得分:0)
你在复习自己:
PlayerChooser.player1Name = textBoxPlayer1Name.Text;
PlayerChooser.player2Name = textBoxPlayer2Name.Text;
textBlockPlayer1Name.Text = PlayerChooser.player1Name;
textBlockPlayer2Name.Text = PlayerChooser.player2Name;
答案 2 :(得分:0)
好的,我发现我的程序到底出了什么问题。我想C#编译器出了问题。因为当我从类名中删除下划线(现在是TwoPlayers504New)时,一切都开始正常工作。
非常感谢微软。