萌新在学习写一个飞行棋
运行时switch那里会出现“未经处理的异常”
Maps是一个字段
```public static int[] Maps = new int[100];
public static string Condition(int i) //声明一个i,给方法里使用
{
string str = " ";
if ((Player[0] == Player[1]) && Player[1] == i)//如果玩家A和玩家B在一起时
{
str = "<>";
}
else if (Player[0] == i)//玩家A
{
str = "A";
}
else if (Player[1] == i)//玩家B
{
str = "B";
}
else
{
switch (Maps[i])
{
case 0://调用上面的用来定义道具得是数字,数组里未经改变的值都是0
Console.ForegroundColor = ConsoleColor.White;
str = "□";//普通格子
break;
case 1:
Console.ForegroundColor = ConsoleColor.Green;
str = "☆";//幸运星
break;
case 2:
Console.ForegroundColor = ConsoleColor.Red;
str = "?";//地雷
break;
case 3:
Console.ForegroundColor = ConsoleColor.Blue;
str = "■";//暂停
break;
case 4:
Console.ForegroundColor = ConsoleColor.Yellow;
str = "卍";//时空隧道
break;
}
}
return str;
}