C# 0 The Complete Reference


MyClass , and that  MyClass



Download 4,07 Mb.
Pdf ko'rish
bet646/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   642   643   644   645   646   647   648   649   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

MyClass

, and that 



MyClass

 defines a parameterless 

constructor. Thus, it is valid for use as a type argument for 

Test

. It must be emphasized that 

it was not necessary for 

MyClass

 to explicitly declare a parameterless constructor. Its default 

constructor would also satisfy the constraint. However, if a class needs other constructors 

in addition to a parameterless one, then it would be necessary to also explicitly declare a 

parameterless version, too.

There are three important points about using 



new( )

. First, it can be used with other 

constraints, but it must be the last constraint in the list. Second, 

new( )

 allows you to 

construct an object using only the parameterless constructor, even when other constructors 

are available. In other words, it is not permissible to pass arguments to the constructor of a 

type parameter. Third, you cannot use 

new( )

 in conjunction with a value type constraint

described next.


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   642   643   644   645   646   647   648   649   ...   1096




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