资源描述:
《C#程序题运行结果题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、三写出运行结果题(1)usingSystem;classProgram{staticvoidMain(){intx=3;Console.Write("星期:");Console.WriteLine((Weekday)x);Console.Write("月份:");Console.WriteLine((Month)x);Console.Write("季节:");Console.WriteLine((Season)x);}enumWeekday{未知=-1,星期天,星期一,星期二,星期三,星期四,星期五,星期六}enum
2、Month{一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月,未知=-1星期:星期三月份:四月季节:3}enumSeason{春,夏=2,秋=4,冬=8}}(2)usingSystem;classProgram{staticvoidMain(){class1c1=newclass1();class1.y=5;c1.Output();class1c2=newclass1();c2.Output();}}publicclassclass1050055{privatestaticintx=0;pu
3、blicstaticinty=x;publicintz=y;publicvoidOutput(){Console.WriteLine(class1.x);Console.WriteLine(class1.y);Console.WriteLine(z);}}(3)usingSystem;classProgram{staticvoidMain(){IAia=newB();Console.WriteLine("{0}{1}{2}{4}",iaisIA,iaisIB,iaisA,iaisA,iaisB,iaisC);}}pu
4、blicinterfaceIA{}publicinterfaceIB:IA{}TrueTrueFalseTruepublicclassA:IA{}publicclassB:IB{}publicclassC:B,IB{}(4)usingSystem;classProgram{staticvoidMain(string[]args){MyClassy=newMyClass();BaseClassx=y;x.i=100;Console.WriteLine("{0},{1}",x.i,y.i);}}classBaseClas
5、s{publicinti;}100,0classMyClass:BaseClass{publicnewinti;}(5)usingSystem;classProgram{staticvoidMain(string[]args){MyClassx=newMyClass();x.testParams(0);x.testParams(0,1);x.testParams(0,1,2);}}classMyClass{publicvoidtestParams(paramsint[]arr){Console.Write("使用Pa
6、rams参数!");}publicvoidtestParams(intx,inty){Console.Write("使用两个整型参数!");使用Params参数!使用两个整型参数!使用Params参数!}}(6)usingSystem;namespaceP7_3{publicclassVirtualInheritSample{publicstaticvoidMain(){DerivedClassc=newDerivedClass();c.Call();}}publicclassBaseClass{publicvoid
7、A(){Console.WriteLine("BaseA");}publicvirtualvoidB(){Console.WriteLine("BaseB");}}publicclassDerivedClass:BaseClass{publicnewvoidA(){Console.WriteLine("DerivedA");}publicoverridevoidB(){Console.WriteLine("DerivedB");}publicvoidCall(){this.A();this.B();((BaseCla
8、ss)this).A();((BaseClass)this).B();}}}(7)usingSystem;namespaceP7_6{publicclassSealedSample{DerivedADerivedBBaseADerivedBpublicstaticvoidMain(){Aa=newA1();a.Output();a=newA2(