最新c#实例源代码.doc

最新c#实例源代码.doc

ID:60215395

大小:91.00 KB

页数:13页

时间:2020-12-03

最新c#实例源代码.doc_第1页
最新c#实例源代码.doc_第2页
最新c#实例源代码.doc_第3页
最新c#实例源代码.doc_第4页
最新c#实例源代码.doc_第5页
资源描述:

《最新c#实例源代码.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、__________________________________________________【实例1-1】usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespace_{classProgram{staticvoidMain(string[]args){System.Console.WriteLine("恭喜你,学会了C#编程!");System.Console.ReadLine();}}}【实例1-2】privatevoidForm1_Load(objectsender,EventArgse){this.

2、Text="这是一窗口!";LabellbShow=newLabel();lbShow.Location=newPoint(40,50);lbShow.AutoSize=true;lbShow.Text="恭喜你学会编程了!";this.Controls.Add(lbShow);int[]x,y;x=newint[5]{1,2,3,4,5};y=newint[5];y=x;foreach(intainy){lbShow.Text+=a.ToString();}this.Controls.Add(lbShow);}【实例2-1】usingSystem;usingSystem.Windows.Fo

3、rms;namespaceTestEnum{收集于网络,如有侵权请联系管理员删除__________________________________________________publicpartialclassTestEnum:Form{//VisualStudio.Net自动生成的构造函数,后文示例将全部省略publicTestEnum(){InitializeComponent();}enumMyEnum{a=101,b,c,d=201,e,f};//声明枚举型privatevoidTestEnum_Load(objectsender,EventArgse){MyEnumx=MyEn

4、um.f;//使用枚举型MyEnumy=(MyEnum)202;stringresult="枚举数x的值为";result+=(int)x;//将x转换为整数result+="枚举数y代表枚举元素"+y;lblShow.Text=result;}}}【实例2-2】usingSystem;usingSystem.Windows.Forms;namespaceTestStru{publicpartialclassTestStru:Form{structStudent//声明结构型{//声明结构型的数据成员publicintno;publicstringname;publiccharsex;pu

5、blicintscore;//声明结构型的方法成员publicstringAnswer(){stringresult="该学生的信息如下:";result+="学号:"+no;//""为换行符result+="姓名:"+name;result+="性别:"+sex;result+="成绩:"+score;returnresult;//返回结果收集于网络,如有侵权请联系管理员删除__________________________________________________}};privatevoidTestEnum_Load(objectsender,EventArgs

6、e){Students;//使用结构型s.no=101;s.name="黄海";s.sex='男';s.score=540;lblShow.Text=s.Answer();//显示该生信息lblShow.Text+=""+DateTime.Now;//显示当前时间}}}【实例2-3】usingSystem;classTestConstant{staticvoidMain(string[]args){Console.WriteLine((0).GetType());//有符号的32位整型常量Console.WriteLine((0U).GetType());//无符号的32位整型常量Co

7、nsole.WriteLine((0L).GetType());//64位的长整型常量Console.WriteLine((0F).GetType());//32位的浮点型常量Console.WriteLine((0D).GetType());//64位的双精度型常量Console.WriteLine((0M).GetType());//128位的小数型常量Console.WriteLine(('

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

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

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