C# 0 The Complete Reference


{0} , and 29 is substituted for  {1}



Download 4,07 Mb.
Pdf ko'rish
bet97/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   93   94   95   96   97   98   99   100   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

{0}

, and 29 is substituted for 



{1}

. Thus, the 

format specifiers identify the location at which the subsequent arguments, in this case 28 

and 29, are displayed within the string. Furthermore, notice that the additional values are 

separated by commas, not + signs.

Here is a variation of the preceding statement that specifies minimum field widths:

Console.WriteLine("February has {0,10} or {1,5} days.", 28, 29);

It produces the following output:

February has         28 or    29 days.

As you can see, spaces have been added to fill out the unused portions of the fields. 

Remember, a minimum field width is just that: the 

minimum

 width. Output can exceed 

that width if needed.

Of course, the arguments associated with a format command need not be constants. For 

example, this program displays a table of squares and cubes. It uses format commands to 

output the values.

// Use format commands.

using System;

class DisplayOptions {

  static void Main() {

    int i;

    Console.WriteLine("Value\tSquared\tCubed");

    for(i = 1; i < 10; i++)

      Console.WriteLine("{0}\t{1}\t{2}", i, i*i, i*i*i);

  }

}

The output is shown here:



www.freepdf-books.com


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   93   94   95   96   97   98   99   100   ...   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