C#语言04-CSharp面向对象编程基础(1).pdf

上传人:asd****56 文档编号:70322151 上传时间:2023-01-19 格式:PDF 页数:32 大小:163.54KB
返回 下载 相关 举报
C#语言04-CSharp面向对象编程基础(1).pdf_第1页
第1页 / 共32页
C#语言04-CSharp面向对象编程基础(1).pdf_第2页
第2页 / 共32页
点击查看更多>>
资源描述

《C#语言04-CSharp面向对象编程基础(1).pdf》由会员分享,可在线阅读,更多相关《C#语言04-CSharp面向对象编程基础(1).pdf(32页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、OO?OO?OO?(?)?(?)?(?)?C#?OO?OO?class Car int colorNumber;int doorNumber;int speed;void Brake()void SpeedUp();void SlowDown()Car myCar=new Car();myCar.SpeedUp();?B?A?:1.?2.?3.?myCar.SpeedUP(10);?C#?C#?C#?C+?C#?”?“?null?+?-?class?class Student?long id;/?char gender;/?int classID;/?class?void ChangeClas

2、s(int aClassID)/?Student student;?new?student=new Student();/?.?/?(?)student.id=200328013203194;?Student student;/?Student?student student=new Student();/?new Student()student=studentstudent Student student2=student;/?studentstudent2000000000000000000000000000000000000000000000 x01abcdef000000000000

3、00000000000000000 x01abcdef2003280132031940000000000000 x01abcdef?Student xiaoMing=new Student();Student xiaoFang=new Student();xiaoMing.gender=M;xiaoFang.gender=F;?xiaoMing.gender?M?xiaoMing?xiaoFang?(xiaoMing=xiaoFang)?false?equals?0 x01abcdef?M?xiaoMing0 x01abcdf5xiaoFang?F?Student xiaoMing=new S

4、tudent();Student xiaoFang=xiaoMing;xiaoMing.gender=M;xiaoFang.gender=F;?xiaoMing.gender?F?xiaoMing?xiaoFang?(xiaoMing=xiaoFang)?true?xiaoMing.equals(xiaoFang)?true?0 x01abcdef?F?xiaoMing0 x01abcdf5xiaoFang?int xiaoMing=100;int xiaoFang=xiaoMing;xiaoFang=200;?xiaoMing?100?(xiaoMing=xiaoFang)?false?10

5、0 xiaoMing200 xiaoFang?C#?ref?out?-?class HelloWorldstatic void change100(int x)System.Console.WriteLine(Inside method,x=+x);x=100;System.Console.WriteLine(Inside method,x=+x);static void Main(string args)int y=10;System.Console.WriteLine(Outside method,y=+y);change100(y);System.Console.WriteLine(Ou

6、tside method,y=+y);?Outside method,y=10Inside method,x=10Inside method,x=100Outside method,y=10?-?class Studentpublic int No;class HelloWorldstatic void change100(Student x)x.No=100;static void Main(string args)Student s=new Student();s.No=10;change100(s);System.Console.WriteLine(s.No=+s.No);?s.No=1

7、00?-refclass HelloWorldstatic void change100(ref int x)System.Console.WriteLine(Inside method,x=+x);x=100;System.Console.WriteLine(Inside method,x=+x);static void Main(string args)int y=10;System.Console.WriteLine(Outside method,y=+y);change100(ref y);System.Console.WriteLine(Outside method,y=+y);?O

8、utside method,y=10Inside method,x=10Inside method,x=100Outside method,y=10?-outclass HelloWorldstatic void change100(int x,out int y)y=x;static void Main(string args)int x=10,y;change100(x,out y);System.Console.WriteLine(y=+y);?out?y=10?(local)?,?automatic?temporary?stack?,?,?,?(?)?new Xxxx()?this?c

9、lass Studentlong id;char gender;int classID;void changeClass(int classID)this.classID=classID;int y=0;for(int x=0;x10;x+)y+=x;for(int x=0;x=0)id=aID;return true;else return false;public static void main(String args)?class Studentpublic int No;class Student private int No;public int GetNo()return No;

10、public void SetNo(int aNo)if(aNo 0)No=aNo;elseNo=0;class Student3private int no;public int Noget return no;setif(value 0)no=value;else no=0;class HelloWorld static void Main(string args)Student3 s=new Student3();s.No=1;?getset?get?set?static?new?public?0?1?class Studentlong id;/?char gender;/?int cl

11、assID;/?class?public Student()id=0;gender=F;classID=0;public Student(long aID,char aGender,int aClassID)id=aID;gender=aGender;classID=aClassID;?C#?C#?.Net?.net?int,string,float,DateTime?.net?80%?.NET Framework?Object.Finalize?Finalize?Finalize?Finalize?Finalize?Finalize?Close?Dispose?Close?Dispose?Dispose?Close?GC?Dispose?GC?Close?C#?IDisposable?using System;class MyFilepublic MyFile()/Open Filepublic void Close()/Close Filepublic void Dispose()Close();GC.SuppressFinalize(this);MyFile()Close();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 其他杂项

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁