{
int die1 = randomNumbers.Next(1, 7);
int die2 = randomNumbers.Next(1, 7);
int sum = die1 + die2;
MessageBox.Show( Convert.ToString(die1) + Convert.ToString(die2) + Convert.ToString(sum));
return sum;
}
现在静态方法返回的是sum 我想把 die1 die2 sum 都单独显示在textBox中怎么搞!!
大神来一个
5 个解决方案
#1
把textBox通过参数传进去,就可以在静态方法中显示
#2
加两个ref或者out参数
#3
大神给段代码学习下
#4
public static int RollDice(out int die1,out int die2,out int sum)
{
die1 = randomNumbers.Next(1, 7);
die2 = randomNumbers.Next(1, 7);
sum = die1 + die2;
// MessageBox.Show( Convert.ToString(die1) + Convert.ToString(die2) + Convert.ToString(sum));
return sum;
}
已成功搞定谢谢!
#5
如果return sum了就不要out sum了
#1
把textBox通过参数传进去,就可以在静态方法中显示
#2
加两个ref或者out参数
#3
把textBox通过参数传进去,就可以在静态方法中显示
大神给段代码学习下
#4
加两个ref或者out参数
public static int RollDice(out int die1,out int die2,out int sum)
{
die1 = randomNumbers.Next(1, 7);
die2 = randomNumbers.Next(1, 7);
sum = die1 + die2;
// MessageBox.Show( Convert.ToString(die1) + Convert.ToString(die2) + Convert.ToString(sum));
return sum;
}
已成功搞定谢谢!
#5
加两个ref或者out参数
public static int RollDice(out int die1,out int die2,out int sum)
{
die1 = randomNumbers.Next(1, 7);
die2 = randomNumbers.Next(1, 7);
sum = die1 + die2;
// MessageBox.Show( Convert.ToString(die1) + Convert.ToString(die2) + Convert.ToString(sum));
return sum;
}
已成功搞定谢谢!