C# 0 The Complete Reference


i  is converted into a  float



Download 4,07 Mb.
Pdf ko'rish
bet111/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   107   108   109   110   111   112   113   114   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

i

 is converted into a 



float

 and then assigned to 



f

. However, because of C#’s strict 

type-checking, not all types are compatible, and thus, not all type conversions are implicitly 

allowed. For example, 



bool

 and 


int

 are not compatible. Fortunately, it is still possible to 

obtain a conversion between incompatible types by using a 

cast.

 A cast performs an explicit 

type conversion. Both automatic type conversion and casting are examined here.

Automatic Conversions

When one type of data is assigned to another type of variable, an 



implicit

type conversion

will take place automatically if

•  The two types are compatible.

•  The destination type has a range that is greater than the source type.

When these two conditions are met, a 



widening conversion 

takes place. For example, the 



int

type is always large enough to hold all valid 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   107   108   109   110   111   112   113   114   ...   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