我的项目中有两个表单(Login和Main).
我想要实现的是,如果登录成功,我必须显示主窗体并关闭登录表单.
我在Login表单中有这个方法,当登录成功时关闭Login表单.但主要形式没有显示.
public void ShowMain()
{
if(auth()) // a method that returns true when the user exists.
{
var main = new Main();
main.Show();
this.Close();
}
else
{
MessageBox.Show("Invalid login details.");
}
}
Run Code Online (Sandbox Code Playgroud)
如果登录过程成功,我尝试隐藏登录表单.但它困扰我,因为我知道当我的程序运行时,登录表单仍然存在,它应该关闭吗?
应该采用什么方法?谢谢...
string FirstName = Console.ReadLine();
if (FirstName.Length > 12)
{
Console.WriteLine(".......................................");
}
if(FirstName.Length<3)
{
Console.WriteLine("....................");
}
Console.WriteLine("...................");
string SecondName = Console.ReadLine();
if (SecondName.Length > 12)
{
Console.WriteLine(".............................");
}
if(SecondName.Length<3)
{
Run Code Online (Sandbox Code Playgroud)
我想停止程序,如果他们按下输入而没有输入值,怎么做?/?