using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace C_Sharp
{
class Program
{
static bool Self()
{
Console.WriteLine("1、个人信息");
Console.WriteLine("2、修改密码");
Console.WriteLine("3、返回上级");
Console.WriteLine("请输入数字");
int myIntSelf;
myIntSelf=Convert.ToInt32(Console.ReadLine());
if (myIntSelf == 3)
return false;
else
return true;
}
static bool Friend()
{
Console.WriteLine("1、添加好友");
Console.WriteLine("2、删除好友");
Console.WriteLine("3、返回上级");
Console.WriteLine("请输入数字");
int myIntFriend;
myIntFriend=Convert.ToInt32(Console.ReadLine());
if (myIntFriend == 3)
return false;
else
return true;
}
static void Main(string[] args)
{
//约定,好友管理 Friend,个人管理 Self。
//显示主界面
Console.WriteLine("1、个人管理");
Console.WriteLine("2、好友管理");
Console.WriteLine("3、退出系统");
Console.WriteLine("请输入数字");
int myCase = Convert.ToInt32(Console.ReadLine());
bool BoolFriend = true, BoolSelf = true, BoolMain = true;
while(BoolMain)
{
if (myCase == 3)
{
Console.WriteLine("拜拜");
BoolMain = false;
}
else if (myCase >= 1 && myCase <= 2)
{
switch (myCase)
{
case 1:
while (BoolSelf)
BoolSelf = Self();
break;
case 2:
while (BoolFriend)
BoolFriend = Friend();
break;
default:
Console.WriteLine("输入错误,请重新输入");
myCase = Convert.ToInt32(Console.ReadLine());
break;
}
}
else
{
Console.WriteLine("输入错误,请重新输入");
myCase = Convert.ToInt32(Console.ReadLine());
}
}
}
}
}代码很短,而且只是一个架子,我发现当我进入二级菜单之后,不能返回上级界面。只要输入3,程序立马停止,必须用鼠标点击窗口来关闭。请问各位高手,我的错误在哪里?
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace C_Sharp
{
class Program
{
static bool Self()
{
Console.WriteLine("1、个人信息");
Console.WriteLine("2、修改密码");
Console.WriteLine("3、返回上级");
Console.WriteLine("请输入数字");
int myIntSelf;
myIntSelf=Convert.ToInt32(Console.ReadLine());
if (myIntSelf == 3)
return false;
else
return true;
}
static bool Friend()
{
Console.WriteLine("1、添加好友");
Console.WriteLine("2、删除好友");
Console.WriteLine("3、返回上级");
Console.WriteLine("请输入数字");
int myIntFriend;
myIntFriend=Convert.ToInt32(Console.ReadLine());
if (myIntFriend == 3)
return false;
else
return true;
}
static void Main(string[] args)
{
//约定,好友管理 Friend,个人管理 Self。
//显示主界面
Console.WriteLine("1、个人管理");
Console.WriteLine("2、好友管理");
Console.WriteLine("3、退出系统");
Console.WriteLine("请输入数字");
int myCase = Convert.ToInt32(Console.ReadLine());
bool BoolFriend = true, BoolSelf = true, BoolMain = true;
while(BoolMain)
{
if (myCase == 3)
{
Console.WriteLine("拜拜");
BoolMain = false;
}
else if (myCase >= 1 && myCase <= 2)
{
switch (myCase)
{
case 1:
while (BoolSelf)
BoolSelf = Self();
break;
case 2:
while (BoolFriend)
BoolFriend = Friend();
break;
default:
Console.WriteLine("输入错误,请重新输入");
myCase = Convert.ToInt32(Console.ReadLine());
break;
}
}
else
{
Console.WriteLine("输入错误,请重新输入");
myCase = Convert.ToInt32(Console.ReadLine());
}
}
}
}
}代码很短,而且只是一个架子,我发现当我进入二级菜单之后,不能返回上级界面。只要输入3,程序立马停止,必须用鼠标点击窗口来关闭。请问各位高手,我的错误在哪里?
解决方案 »
- C# 中的析构函数使用
- 实现这种窗体有那么难吗???郁闷~~~ 再散100分~~~顶着有分~~~
- 怎么遍历Excel并修改各单元个值
- checkedListBox问题!
- SqlDataAdapter.Update()抛出DBConcurrencyException异常
- 关于WinHttp上传文件的服务端接受问题(急,在线等)
- 要VS.Net 2005 Beta2能下载的地址,不要Express Edition版本的,谢谢!
- 有没有c#网络编程的电子书????我愿意和他交换!
- 请教: 关于Windows Services 的安装问题!!!(Thank you!)
- c#winform
- 但是datatable 里面的datetime不可以为null,只能是dbnull.value 有没有类同isnull样的函数
- 各位大神,还能这个东东怎么做的啊?
{
class Program
{
[STAThread]
static void Main(string[] args)
{
//约定,好友管理 Friend,个人管理 Self。
//显示主界面
bool BoolMain = true;
while (BoolMain)
{
Console.WriteLine("1、个人管理");
Console.WriteLine("2、好友管理");
Console.WriteLine("3、退出系统");
Console.WriteLine("请输入数字");
int myCase = Convert.ToInt32(Console.ReadLine());
if (myCase == 3)
{
Console.WriteLine("拜拜");
BoolMain = false;
}
else if (myCase >= 1 && myCase <= 2)
{
switch (myCase)
{
case 1:
//while (BoolSelf)
Self();
break;
case 2:
//while (BoolFriend)
Friend();
break;
default:
Console.WriteLine("输入错误,请重新输入");
myCase = Convert.ToInt32(Console.ReadLine());
break;
}
}
else
{
Console.WriteLine("输入错误,请重新输入");
myCase = Convert.ToInt32(Console.ReadLine());
}
}
} static void Self()
{
while (true)
{
Console.WriteLine("1、个人信息");
Console.WriteLine("2、修改密码");
Console.WriteLine("3、返回上级");
Console.WriteLine("请输入数字");
int myIntSelf;
myIntSelf = Convert.ToInt32(Console.ReadLine());
if (myIntSelf == 3)
return ; }
}
static void Friend()
{
while (true)
{
Console.WriteLine("1、添加好友");
Console.WriteLine("2、删除好友");
Console.WriteLine("3、返回上级");
Console.WriteLine("请输入数字");
int myIntFriend;
myIntFriend = Convert.ToInt32(Console.ReadLine());
if (myIntFriend == 3)
return ;
}
}
}
}
using System.Collections.Generic;
using System.Text;namespace C_Sharp
{
class Program
{
static bool Self()
{
Console.WriteLine("1、个人信息");
Console.WriteLine("2、修改密码");
Console.WriteLine("3、返回上级");
Console.WriteLine("请输入数字");
int myIntSelf;
myIntSelf = Convert.ToInt32(Console.ReadLine());
if (myIntSelf == 3)
{
Main(null);
return false;
}
else
{
return true;
}
}
static bool Friend()
{
Console.WriteLine("1、添加好友");
Console.WriteLine("2、删除好友");
Console.WriteLine("3、返回上级");
Console.WriteLine("请输入数字");
int myIntFriend;
myIntFriend = Convert.ToInt32(Console.ReadLine());
if (myIntFriend == 3)
{
Main(null);
return false;
}
else
{
return true;
}
}
static void Main(string[] args)
{
//约定,好友管理 Friend,个人管理 Self。
//显示主界面
Console.WriteLine("1、个人管理");
Console.WriteLine("2、好友管理");
Console.WriteLine("3、退出系统");
Console.WriteLine("请输入数字");
int myCase = Convert.ToInt32(Console.ReadLine());
bool BoolFriend = true, BoolSelf = true, BoolMain = true;
while (BoolMain)
{
if (myCase == 3)
{
Console.WriteLine("拜拜");
BoolMain = false;
}
else if (myCase >= 1 && myCase <= 2)
{
switch (myCase)
{
case 1:
while (BoolSelf)
BoolSelf = Self();
break;
case 2:
while (BoolFriend)
BoolFriend = Friend();
break;
default:
Console.WriteLine("输入错误,请重新输入");
myCase = Convert.ToInt32(Console.ReadLine());
break;
}
}
else
{
Console.WriteLine("输入错误,请重新输入");
myCase = Convert.ToInt32(Console.ReadLine());
}
} }
}
}
感谢 sdfkfkd 对我思路的改进,并且让我看到当函数是void的时候,return仍然可以应用。
感谢 xu56180825 对我错误的指出和回答,Main(null),哈,我太粗心了。
肯来看我的程序,修改我的程序,帮助我进步。真是非常感谢。
while(BoolMain)
{
Console.WriteLine("1、个人管理");
Console.WriteLine("2、好友管理");
Console.WriteLine("3、退出系统");
Console.WriteLine("请输入数字");
myCase = Convert.ToInt32(Console.ReadLine());
if (myCase == 3)
{
Console.WriteLine("拜拜");
BoolMain = false;
}
else if (myCase >= 1 && myCase <= 2)
{
switch (myCase)
{
case 1:
while (BoolSelf)
BoolSelf = Self();
break;
case 2:
while (BoolFriend)
BoolFriend = Friend();
break;
default:
Console.WriteLine("输入错误,请重新输入");
myCase = Convert.ToInt32(Console.ReadLine());
break;
}
}
else
{
Console.WriteLine("输入错误,请重新输入");
myCase = Convert.ToInt32(Console.ReadLine());
}
}
谢谢各位大神。