C# 0 The Complete Reference



Download 4,07 Mb.
Pdf ko'rish
bet784/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   780   781   782   783   784   785   786   787   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

N

OTE

N

OTE

Some methods defined by the structures that correspond to the built-in value types take a 

parameter of type 

IFormatProvider

 or 

NumberStyles

.

 IFormatProvider



 is briefly described 

later in this chapter. 

NumberStyles

 is an enumeration found in the 

System.Globalization

namespace. The topic of formatting is discussed in Chapter 22.

The Integer Structures

The integer structures are

Byte

SByte


Int16

UInt16


Int32

UInt32


Int64

UInt64


www.freepdf-books.com


624

 

P a r t   I I :  



E x p l o r i n g   t h e   C #   L i b r a r y

Each of these structures contains the same methods. They are shown in Table 21-2. The only 

difference from structure to structure is the return type of 

Parse( )

. For each structure, 



Parse( )

returns a value of the type represented by the structure. For example, for 



Int32

,

Parse( )

returns an 

int

 value. For 



UInt16

,

Parse( )

 returns a 

ushort

 value. For an example that 

demonstrates

Parse( )

, see Chapter 14.

In addition to the methods shown in Table 21-2, the integer structures also define the 

following



const

 fields:


MaxValue

MinValue


For each structure, these fields contain the largest and smallest value that type of integer 

can hold.

All of the integer structures implement the following interfaces: 

IComparable

,

IComparable

,

IConvertible

,

IFormattable

, and 

IEquatable

, where 


T

 is replaced 

by the corresponding data type. For example, 

T

 will be replaced with 



int

 for 


Int32

.

Method



Meaning

public int CompareTo(object 



v

)

Compares the numerical value of the invoking object 



with that of 

v.

 Returns zero if the values are equal. 

Returns a negative value if the invoking object has a 

lower value. Returns a positive value if the invoking 

object has a greater value.

public int CompareTo(



type v

)

Compares the numerical value of the invoking object 



with that of 

v.

 Returns zero if the values are equal. 

Returns a negative value if the invoking object 

has a lower value. Returns a positive value if the 

invoking object has a greater value. In this version of 

CompareTo( )

,

type

 explicitly specifies the data type

such as in 

System.Int32.CompareTo(int 



v

)

.



public override bool Equals(object 

v

)

Returns true if the value of the invoking object equals 



the value of 

v.

public bool Equals(



type v

)

Returns true if the value of the invoking object equals 



the value of 

v. 

In this version of 

Equals( )

,

type

explicitly specifies the data type, such as in 

System.Int32.Equals(int



v

)

.



public override int GetHashCode( )

Returns the hash code for the invoking object.

public TypeCode GetTypeCode( )

Returns the 

TypeCode

 enumeration value for the 

equivalent value type. For example, for 

Int32


, the type 

code is 


TypeCode.Int32

.

public static 



retType

 Parse(string 



str

)

Returns the binar y equivalent of the numeric string in 



str.

 If the string does not represent a numeric value as 

defined by the structure type, an exception is thrown. 

retType

 is a placeholder for the actual type of data 

returned based on which numeric structure is used. 

For example, for 

Int32

,

retType



 will be 

int


.

T

ABLE



 21-2 

Methods Suppor ted by the Integer Structures

www.freepdf-books.com



Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   780   781   782   783   784   785   786   787   ...   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