从另一个类调用main() [英] Calling Main( ) from another class
本文介绍了从另一个类调用main()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为类 TestMaze
。我有一个名为另一类 DisplayHome
其中有一个名为 GAMEOVER()
方法:
I have a class named TestMaze
. I have another class named DisplayHome
which has a method called gameOver()
:
public void gameOver()
{
Console.Write("GAME OVER!");
Console.Write("Play Again? Y/N");
if(char.ToLower(Convert.ToChar(Console.Read())=='y')
//Main()
else
Environment.Exit(1);
}
我如何可以调用Main方法结果
? PS,它们具有相同的命名空间。我只需要知道我怎么能再次调用的主要方法。
How can I call the Main method?
PS. they have the same namespace. I just need to know how can I call the Main method again.
推荐答案
您应该有你的主要内部)一个play()方法...和GAMEOVER(如果用户输入Y应该调用播放()。
You should have a Play() method inside your Main... and GameOver() should call Play() if user enters 'y'.
这篇关于从另一个类调用main()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文