实验报告四 Visual C#.NET程序设计教程

实验报告四 Visual C#.NET程序设计教程

ID:47850434

大小:181.47 KB

页数:9页

时间:2019-11-28

实验报告四 Visual C#.NET程序设计教程_第1页
实验报告四 Visual C#.NET程序设计教程_第2页
实验报告四 Visual C#.NET程序设计教程_第3页
实验报告四 Visual C#.NET程序设计教程_第4页
实验报告四 Visual C#.NET程序设计教程_第5页
资源描述:

《实验报告四 Visual C#.NET程序设计教程》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、攀枝花学院实验报告实验课程:VisualC#.NET程序设计教程实验项目:上机实验6实验日期:2015.05.12系:数计学院成绩:一、实验目的1、初步掌握常用集合的创建和操作方法。2、初步掌握索引器的定义和使用。3、初步掌握泛型接口、泛型类、泛型属性和泛型方法的使用。二、实验要求1.熟悉VisualStudio.Net2010的基本操作方法。2.认真阅读本章相关内容,尤其是案例。3.实验前进行程序设计,完成源程序的编写任务。4.反复操作,直到不需要参考教材、能熟练操作为止。三、实验步骤1、设计一个Windows应用程序,定义一个Teacher类,包含姓名和职称两个字段和一个输出自己

2、信息的方法,并用ArrayList实现与实例6_1相同的功能。源程序如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Collections;namespaceTest4_1{publicpartialclassForm1:Form{publicForm1(){Initia

3、lizeComponent();}publicclassTeacher{privatestringname;privatestringjob;publicTeacher(stringname,stringjob)-8-{this.name=name;this.job=job;}publicstringGetMessage(){returnstring.Format("姓名:{0}职称:{1}。",this.name,this.job);}}ArrayLista=newArrayList();privatevoidShow(){foreach(objectbtObjina){Tea

4、cherbtErgodic=(Teacher)btObj;lblShow.Text+=""+btErgodic.GetMessage();}}privatevoidbtAdd_Click(objectsender,EventArgse){Teacherx=newTeacher(txtName.Text,txtJob.Text);a.Add(x);lblShow.Text="";Show();}privatevoidbtInster_Click(objectsender,EventArgse){intIndex=Convert.ToInt32(txtIndex.Text);Teac

5、herx=newTeacher(txtName.Text,txtJob.Text);a.Insert(Index,x);lblShow.Text="";Show();}privatevoidbtDelete_Click(objectsender,EventArgse){intIndex=Convert.ToInt32(txtIndex.Text);a.RemoveAt(Index);lblShow.Text="";Show();}privatevoidbtErgodic_Click(objectsender,EventArgse)-8-{lblShow.Text="";Show();

6、}}}运行结果如图所示:1、设计一个Windows应用程序,定义一个Student类,包含学号和姓名两个字段,并定义一个班级类ClassList,该类包括一个Student集合,使用索引器访问该集合,实现与实例6_3类似的功能。源程序如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespa

7、ceTest4_2{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}-8-publicclassStudent{privatestringnumber;privatestringname;publicStudent(stringnumber,stringname){this.number=number;this.name=name;}publicstringNumber{g

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。