资源描述:
《超级简单的C#程序题》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、超级简单的C#编程题目1.68页第三题运行结果:2.汽车类3.namespaceCarInformationApplication4.{5.classProgram6.{7.classCar8.{9.publicstringCarID;10.publicstringCarName;11.publicstringCarLogo;12.publicstringRun;13.enumrun{开动=1,停止};14.publicvoidRuned()15.{16.Randomr1=newRandom();17.inta=r1.Next(1,2);18.Run=((r
2、un)a).ToString();19.}20.publicvoidPrintOne()21.{22.23.Console.WriteLine("{0},{1},{2},{3}",CarID,CarName,CarLogo,Run);24.}25.publicCar()26.{}27.publicCar(stringID,stringcarname)28.{29.CarID=ID;30.CarName=carname;31.}32.publicCar(stringID,stringcarname,stringcarlogo)33.{34.CarID=ID;3
3、5.CarName=carname;36.CarLogo=carlogo;37.}38.}2.staticvoidMain(string[]args)3.{4.Carc1=newCar();5.c1.CarID="1234567";6.c1.CarName="lisi";7.c1.CarLogo="奔驰";8.c1.Runed();9.c1.PrintOne();10.Carc2=newCar("1314100","王五");11.c2.Runed();12.c1.PrintOne();13.Carc3=newCar("12345689","张三","奔驰"
4、);14.c3.Runed();15.c3.PrintOne();16.Console.ReadLine();17.}18.}19.}运行结果:3.结构体4.namespacemystruct5.{6.classProgram7.{8.enumSubject{GIS=1,GEO,CDR}9.classBj10.{11.publicstudent[]stu=newstudent[2];12.}13.structstudent14.{15.publicstringxh;16.publicstringxm;17.publicstringxb;18.publicSu
5、bjectzy;19.publicvoidgetvalue()20.{21.Console.WriteLine("请输学号:");22.xh=Console.ReadLine();23.Console.WriteLine("请输入姓名:");24.xm=Console.ReadLine();25.Console.WriteLine("请输入性别:");26.xb=Console.ReadLine();27.Console.WriteLine("请输入专业:1GIS,2GEO,3CDR");28.zy=(Subject)int.Parse(Console.Re
6、adLine());29.30.}31.publicvoidprinttheone()32.{33.Console.WriteLine("{0},{1},{2},{3}",xh,xm,xb,zy);34.}35.}3.staticvoidMain(string[]args)4.{5.Bj[]mybj=newBj[3];6.for(inti=0;i7、;12.}13.}14.for(inti=0;i8、{11.stringID;12.stringName