C# 0 The Complete Reference



Download 4,07 Mb.
Pdf ko'rish
bet275/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   271   272   273   274   275   276   277   278   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

The Main( ) Method

Up to this point, you have been using one form of 



Main( )

. However, it has several 

overloaded forms. Some can be used to return a value, and some can receive arguments. 

Each is examined here.



Return Values from Main( )

When a program ends, you can return a value to the calling process (often the operating 

system) by returning a value from 

Main( )

. To do so, you can use this form of 



Main( )

:

static int Main( )



Notice that instead of being declared 

void

, this version of 



Main( )

 has a return type of 



int

.

Usually, the return value from 



Main( )

 indicates whether the program ended normally 

or due to some abnormal condition. By convention, a return value of zero usually indicates 

normal termination. All other values indicate some type of error occurred.



Pass Arguments to Main( )

Many programs accept what are called 



command-line

 arguments. A command-line argument 

is the information that directly follows the program’s name on the command line when it is 

executed. For C# programs, these arguments are then passed to the 



Main( )

 method. To receive 

the arguments, you must use one of these forms of 

Main( )

:

static void Main(string[ ] 



args

)

static int Main(string[ ] 



args

)

The first form returns 



void

; the second can be used to return an integer value, as described 

in the preceding section. For both, the command-line arguments are stored as strings in the 

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   271   272   273   274   275   276   277   278   ...   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