C# 0 The Complete Reference


Semicolons, Positioning, and Indentation



Download 4,07 Mb.
Pdf ko'rish
bet83/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   79   80   81   82   83   84   85   86   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

Semicolons, Positioning, and Indentation

In C#, the semicolon signals the end of a statement



.

 That is, each individual statement must 

end with a semicolon.

As you know, a block is a set of logically connected statements that are surrounded by 

opening and closing braces. A block is 

not

 terminated with a semicolon. Since a block is a 

group of statements, it makes sense that a block is not terminated by a semicolon; instead, 

the end of the block is indicated by the closing brace.

C# does not recognize the end of the line as the end of a statement—only a semicolon 

terminates a statement. For this reason, it does not matter where on a line you put a 

statement. For example, to C#,

x = y;


y = y + 1;

Console.WriteLine(x + " " + y);

is the same as

x = y;  y = y + 1;  Console.WriteLine(x + " " + y);

Furthermore, the individual elements of a statement can also be put on separate lines. For 

example, the following is perfectly acceptable:

Console.WriteLine("This is a long line of output" +

                   x + y + z +

                   "more output");

Breaking long lines in this fashion is often used to make programs more readable. It can also 

help prevent excessively long lines from wrapping.

www.freepdf-books.com




32

 

P a r t   I :  



T h e   C #   L a n g u a g e

You may have noticed in the previous examples that certain statements were indented. 

C# is a free-form language, meaning that it does not matter where you place statements 

relative to each other on a line. However, over the years, a common and accepted indentation 

style has developed that allows for very readable programs. This book follows that style, 

and it is recommended that you do so as well. Using this style, you indent one level after 

each opening brace and move back out one level after each closing brace. There are certain 

statements that encourage some additional indenting; these will be covered later.




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   79   80   81   82   83   84   85   86   ...   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