C# 0 The Complete Reference


PART II C h a p t e r   2 2



Download 4,07 Mb.
Pdf ko'rish
bet849/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   845   846   847   848   849   850   851   852   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART II

C h a p t e r   2 2 :  

S t r i n g s   a n d   F o r m a t t i n g    

685


of methods format data, including 

Console.WriteLine( )

,

String.Format( )

, and the 

ToString( )

method defined for the numeric structure types. The same approach to formatting is used by 

all three; once you have learned to format data for one, you can apply it to the others.

Formatting Overview

Formatting is governed by two components: 



format specifiers

 and 


format providers.

 The form 

that the string representation of a value will take is controlled through the use of a format 

specifier. Thus, it is the format specifier that dictates how the human-readable form of the 

data will look. For example, to output a numeric value using scientific notation, you will 

use the E format specifier.

In many cases, the precise format of a value will be affected by the culture and 

language in which the program is running. For example, in the United States, money is 

represented in dollars. In Europe, money is represented in euros. To handle the cultural 

and language differences, C# uses format providers. A format provider defines the way 

that a format specifier will be interpreted. A format provider is created by implementing 

the


IFormatProvider

 interface, which defines the 



GetFormat( )

 method. Format providers 

are predefined for the built-in numeric types and many other types in the .NET Framework. 

In general, you can format data without having to worry about specifying a format 

provider, and format providers are not examined further in this book.

To format data, include a format specifier in a call to a method that supports formatting. 

The use of format specifiers was introduced in Chapter 3, but is worthwhile reviewing here. 

The discussion that follows uses 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   845   846   847   848   849   850   851   852   ...   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