c#实验源码.doc
上传人:qw****27 上传时间:2024-09-12 格式:DOC 页数:14 大小:80KB 金币:15 举报 版权申诉
预览加载中,请您耐心等待几秒...

c#实验源码.doc

c#实验源码.doc

预览

免费试读已结束,剩余 4 页请下载文档后查看

15 金币

下载此文档

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

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

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

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

实验一创建控制台程序:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleApplication1{classProgram{staticvoidMain(string[]args){Console.WriteLine("holloword!");}}}创建windows窗口程序:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespaceWindowsFormsApplication1{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}privatevoidlabel1_Click(objectsender,EventArgse){textBox1.Text="holloword!";}privatevoidbutton1_Click(objectsender,EventArgse){label1.Text="你好!";}}}创建web应用程序:<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="Default.aspx.cs"Inherits="WebApplication1._Default"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>C3web应用程序</title></head><body><formid="form1"runat="server"><div><center>holloword!</center></div></form></body></html>实验一主要掌握的知识点是:创建以上几个不同个程序的方法和步骤;熟悉标签,按钮,控制台格式化输出语句。实验二对象的继承和多态类实现:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespace对象的继承和多态{abstractclassShape{abstractpublicdoublearear();abstractpublicdoubleperimeter();abstractpublicvoiddisplay();}classCircle:Shape{privatedoublei;privatedoublej;privatedoubler;publicCircle(doublea,doubleb,doublec){this.i=a;this.j=b;this.r=c;}publicoverridedoublearear(){return3.14*r*r;}publicoverridedoubleperimeter(){return2*3.14*r;}publicoverridevoiddisplay(){Console.WriteLine("圆心是"+"("+i+","+j+")"+"半径是"+r+"圆面积是:"+arear()+"圆周长是"+perimeter());}}classTriangle:Shape{privatedoublea;privatedoubleb;privatedoublec;privatedoublech;publicTriangle(doublei,doublej,doublek,doublep){this.a=i;this.b=j;this.c=k;this.ch=p;}publicoverridedoublearear(){return