C# 0 The Complete Reference


double  (2.2) to  int



Download 4,07 Mb.
Pdf ko'rish
bet256/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   252   253   254   255   256   257   258   259   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

double

 (2.2) to 



int

, which is the type 

of

nums

 in 


MinVal( )

.

When using 



params

, you need to be careful about boundary conditions because a 



params

 parameter can accept any number of arguments—



even zero!

 For example, it is 

syntactically valid to call 

MinVal( )

 as shown here:

min = ob.MinVal(); // no arguments

min  = ob.MinVal(3); // 1 argument

This is why there is a check in 

MinVal( )

 to confirm that at least one element is in the 



nums

array before there is an attempt to access that element. If the check were not there, then a 

runtime exception would result if 

MinVal( )

 were called with no arguments. (Exceptions are 

described in Chapter 13.) Furthermore, the code in 

MinVal( )

 was written in such a way as to 

permit calling 

MinVal( )

 with one argument. In that situation, the lone argument is returned.

A method can have normal parameters and a variable-length parameter. For example, 

in the following program, the method 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   252   253   254   255   256   257   258   259   ...   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