控制台程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test3_5
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("1.苹果");
Console.WriteLine("2.香蕉");
Console.WriteLine("3.水蜜桃");
Console.WriteLine("请选择一种水果");
string str = Console.ReadLine(); //可以用var声明局部变量
int i = Int32.Parse(str);
switch (i)
{
case 1:
Console.WriteLine("你选择了苹果");
break;
case 2:
Console.WriteLine("你选择了香蕉");
break;
case 3:
Console.WriteLine("你选择了水蜜桃");
break;
default:
Console.WriteLine("输入不正确");
break;
}
}
}
}