namespace demo1009
{
internal class Program
{
//enum Role //遵循大驼峰命名法
//{
// 射手,坦克,法师,战士,辅助,刺客// 每个枚举的名字都对应着一个编号 从0开始
//}
enum State {
onLine,OffLine,Busy
}
//enum Role
//{
// 星期一,星期二,星期三,星期四,星期五,星期六,星期七 //
//}
static void Main(string[] args)
{
Console.WriteLine("请输入状态编号");
string strNum = Console.ReadLine();
switch(strNum)
{
case "1":
Console.WriteLine(State.onLine);
break;
case "2":
Console.WriteLine(State.onLine );
break;
case "3":
Console.WriteLine(State.OffLine );
break;
case "4":
Console.WriteLine(State.Busy );
break;
default:
Console.WriteLine("无状态");
break;
}
//Role role = Role.射手;
//string strRole = Convert.ToString(role);//枚举类型的名字可以转成字符串
//int intRole = Convert.ToInt32(role);//可以转成 整数
////字符串转成枚举类型的值
//Role Role2 = (Role)Enum.Parse(typeof(Role),"射手");
//if(Role2==Role.战士 )
//{
// Console.WriteLine("防御加10");
//}
//Console.WriteLine(strRole +1);
//Console.WriteLine(intRole);
//Role day = Role.星期一;
//int num2 = 2;
////函数 返回多个值 同个类型返回数组 不同类型多个值 out参数 在形参后面加上out
//static bool isPrime (int num,out int num1,int num3)
//{
// num1 = 1; //定义out参数后面的变量 在函数内部必须要赋值
// return true;
//}
//isPrime(10, out num2,12); //将num1 的值赋给num2
//Console.WriteLine(num2);
//Console.WriteLine("输入用户名");
//string name = Console.ReadLine();
//Console.WriteLine("输入密码");
//string pwd = Console.ReadLine();
//string msg;
//static bool islogin(string name, string pwd,out string msg2)
//{
// if(name =="admin"&&pwd=="1234")
// {
// msg2 = "登录成功";
// return true;
// }
// else if(name == "admin"&&pwd!="1234")
// {
// msg2 = "密码错误";
// }
// else if(name!="admin"&&pwd=="1234")
// {
// msg2 = "用户名出错";
// }
// else
// {
// msg2 = "用户名密码出错";
// }
// return false;
//}
//islogin(name, pwd, out msg);
//Console.WriteLine (msg);
//ref 同样还是将函数中的变量的值带出来 不一样的是在函数可以不用赋值 外部接受的变量需要赋初始值
//青蛙
/* Console.Write("请输入台阶数");
int n = Convert.ToInt32(Console.ReadLine());
static int frog(int n)
{
if (n == 1) return 1;
if (n == 2) return 2;
return frog(n - 1) + frog(n - 2);
}
Console.WriteLine(frog(n));
*/
//Console.Write("请输入盘子");
//int n = Convert.ToInt32(Console.ReadLine());
//static void hanoi(int n,string start,string middle ,string end)
//{
// if(n==1)
// {
// Console.WriteLine("从{0}经过{1}移到{2}",start,middle,end);
// return;
// }
// hanoi(n-1,start,end,middle);//将n-1 一个盘子移到中间的柱子上
// hanoi(1, start, middle, end);
// //剩下n-1个盘子
// hanoi(n - 1, middle, start, end);
//}
//hanoi(n,"A","B","C");
//常量 const 关键字
//const int num = 1;
////枚举类型
//string[] roles = { "刺客", "战士", "法师", "辅助", "射手", "坦克" };//在使用的地方不直观 ,不好维护
}
}
}