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


// Very verbose manner in which to declare a bool



Download 21,46 Mb.
Pdf ko'rish
bet197/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   193   194   195   196   197   198   199   200   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

// Very verbose manner in which to declare a bool.

System.Boolean b4 = false;

Console.WriteLine("Your data: {0}, {1}, {2}, {3}, {4}, {5}",

myInt, myString, b1, b2, b3, b4);

Console.WriteLine();

}

“New-ing” Intrinsic Data Types

All intrinsic data types support what is known as a default constructor (see Chapter 5). In a nutshell,

this feature allows you to create a variable using the new keyword, which automatically sets the vari-

able to its default value:

• bool types are set to false.

• Numeric data is set to 0 (or 0.0 in the case of floating-point data types).

C H A P T E R   3  



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



82

8849CH03.qxd  9/24/07  11:07 AM  Page 82




• char types are set to a single empty character.

• DateTime types are set to 1/1/0001 12:00:00 AM.

• Object references (including strings) are set to null.

Although it is more cumbersome to use the new keyword when creating a basic data type vari-

able, the following is syntactically well-formed C# code:

static void NewingDataTypes()

{

Console.WriteLine("=> Using new to create intrinsic data types:");



bool b = new bool();              // Set to false.

int i = new int();                // Set to 0.

double d = new double();          // Set to 0.

DateTime dt = new DateTime();     // Set to 1/1/0001 12:00:00 AM

Console.WriteLine("{0}, {1}, {2}, {3}", b, i, d, dt);

Console.WriteLine();

}


Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   193   194   195   196   197   198   199   200   ...   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