我打算在文本框中显示结果。我的代码是这样的:
private void run_Click(object sender, EventArgs e)
{
GeneticAlgorithm MyGeneticAlgorithm = new GeneticAlgorithm();
GeneticAlgorithm.GAoutput ShowResult = MyGeneticAlgorithm.GA();
string output;
output = ShowResult;
this.Output.Text = output;
}
class GeneticAlgorithm
{
public void reset()
{
MessageBox.Show("fine");
}
public void Initial()
{
MessageBox.Show("Good");
}
public class GAoutput
{
public string Generation;
}
public GAoutput GA()
{
GAoutput OneGeneration = new GAoutput();
OneGeneration.Generation = "bad";
return OneGeneration;
}
}
运行后,它给我的结果是:WindowsFormsApplication1.GeneticAlgorithm+GAoutput
任何人都可以帮助我吗?太感谢了!