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



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



Note

Recall from Chapter 1 that CLS-compliant .NET code can be used by any managed programming lan-

guage. If you expose non–CLS-compliant data from your programs, other languages may not be able to make

use of it.

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



80

Table 3-4.

The Intrinsic Data Types of C#

CLS 

C# Shorthand

Compliant?

System Type

Range

Meaning in Life

bool


Yes

System.Boolean

True or false

Represents truth or

falsity

sbyte


No

System.SByte

–128 to 127

Signed 8-bit number

byte

Yes


System.Byte

0 to 255


Unsigned 8-bit

number


short

Yes


System.Int16

–32,768 to 32,767

Signed 16-bit

number


ushort

No

System.UInt16



0 to 65,535

Unsigned 16-bit

number

int


Yes

System.Int32

–2,147,483,648 to 

Signed 32-bit 

2,147,483,647

number


uint

No

System.UInt32



0 to 4,294,967,295

Unsigned 32-bit

number

long


Yes

System.Int64

–9,223,372,036,854,775,808 to 

Signed 64-bit 

9,223,372,036,854,775,807

number


ulong

No

System.UInt64



0 to 18,446,744,073,709,551,615

Unsigned 64-bit

number

char


Yes

System.Char

U+0000 to U+ffff

Single 16-bit Unicode

character

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




CLS 

C# Shorthand

Compliant?

System Type

Range

Meaning in Life

float


Yes

System.Single

±1.5 ✕ 10

45 to ±3.4 ✕ 1038



32-bit floating-point

number


double

Yes


System.Double

±5.0 ✕ 10

324 to ±1.7 ✕ 10308



64-bit floating-point

number


decimal

Yes


System.Decimal

±1.0 ✕ 10e

28 to ±7.9 ✕ 10e28



96-bit signed number

string


Yes

System.String

Limited by system memory

Represents a set of

Unicode characters

object


Yes

System.Object

Can store any type in an 

The base class of all 

object variable

types in the .NET

universe

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



81



Note

By default, a real numeric literal on the right-hand side of the assignment operator is treated as 

double

.

Therefore, to initialize a 



float

variable, use the suffix 

f

or 


F

(for example,

5.3F

).

Each of the numerical types (short, int, and so forth) map to a corresponding structure in the



System namespace. In a nutshell, structures are “value types” allocated on the stack. On the other

hand, string and object are “reference types,” meaning the variable is allocated on the managed

heap. You will examine full details of value and reference types in Chapter 4; however, for the time

being, simply understand that value types can be allocated into memory very quickly and have a

very fixed and predictable lifetime. 

Variable Declaration and Initialization

When you are declaring a data type as a local variable (e.g., a variable within a member scope), you

do so by specifying the data type followed by the variable’s name. You’ll see how this is done by way

of a few examples. Create a new Console Application project named BasicDataTypes. Update the

Program class with the following helper method that is called from within Main():

static void LocalVarDeclarations()

{

Console.WriteLine("=> Data Declarations:");



// Local variables are declared as so:


Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   190   191   192   193   194   195   196   197   ...   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