没有合适的资源?快使用搜索试试~ 我知道了~
C# 微软基础教程PPT-2
3星 · 超过75%的资源 需积分: 0 110 下载量 83 浏览量
2008-03-26
16:11:27
上传
评论
收藏 1.33MB PPT 举报
温馨提示
试读
64页
C# 微软基础教程PPT-2
资源详情
资源评论
资源推荐
Module 7: Creating
Module 7: Creating
and Destroying
and Destroying
Objects
Objects
Overview
Using Constructors
Using Constructors
Initializing Data
Initializing Data
Objects and Memory
Objects and Memory
Using Destructors
Using Destructors
In this module, you will learn what happens when an
In this module, you will learn what happens when an
object is created, how to use constructors to initialize
object is created, how to use constructors to initialize
objects, and how to use destructors to destroy
objects, and how to use destructors to destroy
objects. You will also learn what happens when an
objects. You will also learn what happens when an
object is destroyed and how garbage collection
object is destroyed and how garbage collection
reclaims memory.
reclaims memory.
After completing this module, you
will be able to:
Use constructors to initialize objects.
Use constructors to initialize objects.
Create overloaded constructors that
Create overloaded constructors that
can accept varying parameters.
can accept varying parameters.
Describe the lifetime of an object and
Describe the lifetime of an object and
what happens when it is destroyed.
what happens when it is destroyed.
Create destructors and use Finalize
Create destructors and use Finalize
methods.
methods.
Using Constructors
Creating Objects
Creating Objects
Using the Default Constructor
Using the Default Constructor
Overriding the Default Constructor
Overriding the Default Constructor
Overloading Constructors
Overloading Constructors
Constructors are special methods that you use to
Constructors are special methods that you use to
initialize objects when you create them. Even if you do
initialize objects when you create them. Even if you do
not write a constructor yourself, a default constructor is
not write a constructor yourself, a default constructor is
provided for you whenever you create an object from a
provided for you whenever you create an object from a
reference type. In this section, you will learn how to use
reference type. In this section, you will learn how to use
constructors to control what
constructors to control what
happens when an object is created.
happens when an object is created.
How new and Instance
Constructors Collaborate
It is important to realize how closely
It is important to realize how closely
new
new
and instance constructors collaborate to
and instance constructors collaborate to
create objects. The only purpose of
create objects. The only purpose of
new
new
is
is
to acquire raw uninitialized memory. The
to acquire raw uninitialized memory. The
only purpose of an instance constructor is to
only purpose of an instance constructor is to
initialize the memory and convert it into an
initialize the memory and convert it into an
object that is ready to use. Speci+cally,
object that is ready to use. Speci+cally,
new
new
is not involved with initialization in any way,
is not involved with initialization in any way,
and instance constructors are not
and instance constructors are not
involved in acquiring memory in any way.
involved in acquiring memory in any way.
剩余63页未读,继续阅读
机器人
- 粉丝: 2151
- 资源: 37
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论2