namespaceConsoleApp1{internalclassProgram{staticvoidMain(string[] args){Console.WriteLine("请输入一个数");int x=Convert.ToInt32(Console.ReadLine());Console.WriteLine("请输入运算类型");char z=Convert.ToChar(Console.ReadLine());Console.WriteLine("请输入另一个数字");int y=Convert.ToInt32(Console.ReadLine());switch(z){case'+':Console.WriteLine("计算结果{0}",x+y);break;case'-':Console.WriteLine("计算结果是{0},x-y");break;case'*':Console.WriteLine("计算结果是{0}", x * y);break;default:Console.WriteLine("不认识计算类型");break;}}}}
循环语句
while 循环
namespaceConsoleApp1{internalclassProgram{staticvoidMain(string[] args){int a =10;//定义一个局部变量while(a>0){Console.WriteLine("第{0}个 hello world",a);a = a -1;}}}}