预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共15页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

enumweek{sun,mon,tue,wed,thr,fir,sat}; privatevoidbutton1_Click(objectsender,System.EventArgse) { DateTimewk=Convert.ToDateTime(textBox1.Text); weekd=(week)wk.DayOfWeek; label2.Text="thisisthe"+d; } 求星期几 5给一个数组输入数值,如果输入字符时,需要重新输入,如果输入“End”则结束输入,并统计输入的次数。(try-catch-finally) namespaceConsoleApplication2 { classProgram { staticvoidMain(string[]args) { namespaceConsoleApplication3 { classProgram { staticvoidMain(string[]args) {int[]a=newint[10]; stringb; intd=0; boolc=true; while(c) { try { for(inti=0;i<a.Length;i++) { b=Console.ReadLine(); if(b=="END") { c=false; break; } else { a[i]=Convert.ToInt32(b); d=i; } } } catch(FormatException) { Console.WriteLine("请输入的number"); } } Console.WriteLine("输入的次数是:{0}",d+1); Console.ReadLine(); } } } } } 自己定义一个异常类。并引用其实例查看异常的情况 namespaceConsoleApplication1 { publicclassException1111:Exception { publicstringn; publicintsum; publicException1111():base(){} publicException1111(stringa,Exceptione):base(a,e){n=a;sum=1;} publicvoidF() { intnn=Convert.ToInt32(n); for(inti=1;i<=nn;++i) { sum=checked(sum*i); } } publicvoiddisplay() { Console.WriteLine("n!={0}",sum); Console.ReadLine(); } } classProgram { staticvoidMain() { Console.WriteLine("请输入一个数:"); try { Exception1111b=newException1111(); Exceptionee=newException(); stringa=Console.ReadLine(); Exception1111c=newException1111(a,ee); c.F(); c.display(); } catch(FormatExceptionf) { Console.WriteLine("输出格式错误。"); Console.ReadLine(); } catch(OverflowExceptione) { Console.WriteLine("超出数据的范围了。"); Console.ReadLine(); } } } } } } 3假设有20张票,由两个线程来实现一个售票程序,每次线程运行时先检查是否还有票未售出,如果有就按照票号从小到大的顺序售出。 把上面的结果用windows窗体实现。 usingSystem.Threading; namespaceConsoleApplication1 { classSaleTicket { publicbool[]flag; publicintindex; Randomr=newRandom(); publicSaleTicket(intTicketnums) { index=Ticketnums; } publicvoidInital() { flag=newbool[20]; for(inti=0;i<20;++i) { flag[i]=false; } } publicintSale(intIndex) { lock(this) { if(Index>19) { Console.WriteLine("票已卖完."); Console.ReadLine(