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



Download 21,46 Mb.
Pdf ko'rish
bet386/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   382   383   384   385   386   387   388   389   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

The sealed Keyword

C# supplies another keyword, sealed, that prevents inheritance from occurring. When you mark a

class as sealed, the compiler will not allow you to derive from this type. For example, assume you

have decided that it makes no sense to further extend the MiniVan class:



// This class cannot be extended!

sealed class MiniVan : Car

{

}

If you (or a teammate) were to attempt to derive from this class, you would receive a compile-



time error:

// Error! Cannot extend

// a class marked with the sealed keyword!

class DeluxeMiniVan

: MiniVan

{}

Most often, sealing a class makes the best sense when you are designing a utility class. For



example, the System namespace defines numerous sealed classes. You can verify this for yourself

by opening up the Visual Studio 2008 Object Browser (via the View menu) and selecting the

System.String type defined within the mscorlib.dll assembly. Notice in Figure 6-1 the use of the

sealed keyword highlighted in the Summary window.



Figure 6-1.

The base class libraries define numerous sealed types.

Thus, just like the MiniVan, if you attempted to build a new class that extends System.String,

you will receive a compile-time error:


Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   382   383   384   385   386   387   388   389   ...   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