C# 0 The Complete Reference


PART II C h a p t e r   2 1



Download 4,07 Mb.
Pdf ko'rish
bet792/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   788   789   790   791   792   793   794   795   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART II

C h a p t e r   2 1 :  

E x p l o r i n g   t h e   S y s t e m   N a m e s p a c e    

633


public static decimal

     Round(decimal 



v

,

                MidPointRounding 



how

)

Returns the value of 



v

 rounded to the nearest whole 

number using the rounding mode specified by 

how.

The rounding mode applies only to those conditions in 

which

v

 is at the midpoint between two whole numbers. 

public static decimal

     Round(decimal 



v

, int 


decPlaces

,

                MidPointRounding 



how

)

Returns the value of 



v

 rounded to the number of 

decimal places specified by 

decPlaces

(which must be 

between 0 and 28), using the rounding mode specified 

by

how

. The rounding mode applies only to those 

conditions in which 



v

 is at the midpoint between two 

rounded values. 

public static decimal

    Subtract(decimal 

v1

, decimal 



v2

)

Returns 



v1



v2.

public static byte ToByte(decimal 

v

)

Returns the 



byte

 equivalent of 



v.

 Any fractional 

component is truncated. An 

OverflowException

 occurs 

if

v

 is not within the range of a 

byte


.

public static double ToDouble(decimal 



v

)

Returns the 



double

 equivalent of 



v.

 A loss of precision 

may occur because 

double


 has fewer significant digits 

than does 

decimal

.

public static shor t ToInt16(decimal 



v

)

Returns the 



short

 equivalent of 



v.

 Any fractional 

component is truncated. An 

OverflowException

 occurs 

if

v

 is not within the range of a 

short


.

public static int ToInt32(decimal 



v

)

Returns the 



int

 equivalent of 



v.

 Any fractional 

component is truncated. An 

OverflowException

 occurs 

if

v

 is not within the range of an 

int


.

public static long ToInt64(decimal 



v

)

Returns the 



long

 equivalent of 



v.

 Any fractional 

component is truncated. An 

OverflowException

 occurs 

if

v

 is not within the range of a 

long


.

public static long

     ToOACurrency(decimal 

v

)

Conver ts 



v

 into the equivalent OLE Automation 

currency value and returns the result.

public static sbyte ToSByte(decimal 



v

)

Returns the 



sbyte

 equivalent of 



v.

 Any fractional 

component is truncated. An 

OverflowException

 occurs 

if

v

 is not within the range of an 

sbyte


.

public static float ToSingle(decimal 



v

)

Returns the 



float

 equivalent of 



v.

 A loss of precision 

may occur because 

float


 has fewer significant digits 

than does 

decimal

.

public override string ToString( )



Returns the string representation of the value of the 

invoking object in the default format.

public string ToString(string 

format

)

Returns the string representation of the value of 



the invoking object as specified by the format string 

passed in 



format.

Method


Meaning

T

ABLE



 21-7 

Methods Defi ned by 

Decimal

(continued)

www.freepdf-books.com




634

 

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

Char

The structure corresponding to the 



char

 type is 



Char

. It is quite useful because it supplies a 

large number of methods that allow you to process and categorize characters. For example, 

you can convert a lowercase character to uppercase by calling 



ToUpper( )

. You can determine 

if a character is a digit by calling 

IsDigit( )

.

The methods defined by 



Char

 are shown in Table 21-9. Notice that several, such as 



ConvertFromUtf32( ) 

and


ConvertToUtf32( )

, give you the ability to work with both UTF-16 

and UTF-32 Unicode characters. In the past, all Unicode characters could be represented by 

16 bits, which is the size of a 



char

. However, a few years ago the Unicode character set was 

expanded and more than 16 bits are required. Each Unicode character is represented by a 

code point.

 The way that a code point is encoded depends on the Unicode Transformation 

Format (UTF) being used. In UTF-16, the most common code points require one 16-bit 

value, but some need two 16-bit values. When two 16-bit values are needed, two 



char

public string

     ToString(IFormatProvider 

fmtpvdr

)

Returns the string representation of the value of the 



invoking object using the culture-specific information 

specified in 



fmtpvdr.

public string

     ToString(string 

format

,

                 IFormatProvider 



fmtpvdr

)

Returns the string representation of the value of the 



invoking object using the culture-specific information 

specified in 



fmtpvdr

 and the format specified by 



format.

public static ushor t ToUInt16(decimal 



v

)

Returns the 



ushort

 equivalent of 



v.

 Any fractional 

component is truncated. An 

OverflowException

 occurs 

if

v

 is not within the range of a 

ushort


.

public static uint ToUInt32(decimal 



v

)

Returns the 



uint

 equivalent of 



v.

 Any fractional 

component is truncated. An 

OverflowException

 occurs 

if

v

 is not within the range of a 

uint


.

public static ulong ToUInt64(decimal 



v

)

Returns the 



ulong

 equivalent of 



v.

 Any fractional 

component is truncated. An 

OverflowException

 occurs 

if

v

 is not within the range of a 

ulong


.

public static decimal Truncate(decimal 



v

)

Returns the whole-number por tion of 



v.

 Thus, it 

truncates any fractional digits.

public static bool

     Tr yParse(string 

str

, out decimal



 val

)

Attempts to conver t the numeric string in 



str

 into a 


decimal

 value. If successful, the value is stored in 



val

 and true is returned. If no conversion takes place, 

false is returned. This differs from 

Parse( )


, which 

throws an exception on failure. 

public static bool Tr yParse(string 

str

,

                          NumberStyles 



styles

,

IFormatProvider 



fmtpvdr

,

                          out decimal 



val

)

Attempts to conver t the numeric string in 



str

 into a 


decimal

 value using the style information provided 

by

styles

 and the culture-specific format information 

provided by 

fmtpvdr.

 If successful, the value is stored 

in

val

 and true is returned. If no conversion takes 

place, false is returned. This differs from 

Parse( )


,

which throws an exception on failure. 

T

ABLE


 21-7 

Methods Defi ned by 

Decimal

(continued)

Method


Meaning

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   788   789   790   791   792   793   794   795   ...   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