This print for content only-size & color not accurate 7" X 9-1/4" / casebound / malloy



Download 21,46 Mb.
Pdf ko'rish
bet299/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   295   296   297   298   299   300   301   302   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition



Source Code

The RefTypeValTypeParams project is located under the Chapter 4 subdirectory.



Value and Reference Types: Final Details

To wrap up this topic, consider the information in Table 4-3, which summarizes the core distinc-

tions between value types and reference types.

C H A P T E R   4  



C O R E   C #   P R O G R A M M I N G   C O N S T R U C T S, PA RT   I I



135

8849CH04.qxd  10/1/07  10:31 AM  Page 135




Table 4-3.

Value Types and Reference Types Side by Side

Intriguing Question

Value Type

Reference Type

Where is this type allocated?

Allocated on the stack.

Allocated on the managed

heap.

How is a variable represented?



Value type variables 

Reference type variables are 

are local copies.

pointing to the memory

occupied by the allocated

instance.

What is the base type?

Must derive from 

Can derive from any other 

System.ValueType.

type (except System.

ValueType), as long as that

type is not “sealed” (more

details on this in Chapter 6).

Can this type function as a 

No. Value types are always 

Yes. If the type is not sealed, 

base to other types?

sealed and cannot be 

it may function as a base to 

extended.

other types.

What is the default parameter 

Variables are passed by value 

Variables are passed by 

passing behavior?

(i.e., a copy of the variable is 

reference (i.e., the address 

passed into the called function).

of the variable is passed into 

the called function).

Can this type override 

No. Value types are never placed 

Yes, indirectly (more details 

System.Object.Finalize()?

onto the heap and therefore do 

on this in Chapter 8).

not need to be finalized.

Can I define constructors 

Yes, but the default constructor 

But of course!

for this type?

is reserved (i.e., your custom 

constructors must all have 

arguments).

When do variables of this 

When they fall out of the 

When the object is garbage 

type die?

defining scope.

collected.

Despite their differences, value types and reference types both have the ability to implement

interfaces and may support any number of fields, methods, overloaded operators, constants, prop-

erties, and events.




Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   295   296   297   298   299   300   301   302   ...   1830




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish