循环与限制(C#-4)

Posted on Posted in c#
Tips: 本文创建于2013年12月2日,已超过 2 年,内容或图片可能已经失效!

[code lang="csharp"]
//异常捕获

try

{

Console.WriteLine("输入数字:");

name = Console.ReadLine();

a = Convert.ToInt32(name);

}

catch {

Console.WriteLine("您输入的不是数字!");

name = "q";

}

 

} while (name!="q");

Console.WriteLine("退出");

Console.ReadKey();

 

//限制输入,只能输入

string answer = "";

do

{

answer = Console.ReadLine();

while(answer != "y" && answer != "n")

{

Console.WriteLine("只能输入y或n");

answer = Console.ReadLine();

}

}while(answer=="");

Console.WriteLine("退出");

Console.ReadKey();

 

//for循环

for(ini i=0;i<10;i++){}

 

[/code]

» 转载请注明来源:若我若鱼 » 循环与限制(C#-4)

Leave a Reply

Your email address will not be published. Required fields are marked *

one × five =