Professional Documents
Culture Documents
8tohc Void Main (Shingi Aas) : Corvso Le
8tohc Void Main (Shingi Aas) : Corvso Le
ct PTo9am
. w r i t
a Sample
ubing System
claw Porogram
8toHc void Main (SHingI aas)
Corvso Le Tite inu" Hello, LooTlolJ3
ds
Stautement at the toP OL the l e
Th&using 8ystem to
direcHve,
Tt etils the ct comptw
called
colled a using whfcb Contains w qu
wsel
namtspace,
wse
thtSystem
dhe corsole, înput
clouseS a n o
Hethods ke ooTking 9ith
and othut utings
oupuut claus calleol
a ne
Insidle th
th entty point el
ous
Hethod s
called 'Hafn' .this
sben o
pCpoum,
aund it i what 9 s Cecuuted
TUn O ul p o 9 a L m .
,aun QHLay
The Hoin. methool takus a ginale arQumert
iopHonal,bud it
called 'aqs. This avgamend
Shins
SHings
mandline -agtuents
cOun be u s t te passing Co
to Ou po9arm
LEnt s wbee
I h C orsole. iorfte Line ("Hlo, uoold)
4 Tht
namcspoce y Name6poLce o l
claysMyClass { bodia
odu
uttwo namespaces
dyintd
this eomple, we
ve
In
sing MyNamtspa.ce
clauss Progeum {
etaticvofd Hain (&irgt1 axgs) L
Mycla pnOict ntto Hy class t)
Jn this
Codle, uoe ustd tht 'using' direuive do dnpot Hu
MyNameSpac
nam &spa.ce, This allo ws ws to T to t
clas fthout hawing to i a t y J t rane uoitb
Hyclau
Ahe namespaLce p i
olata
ain a Pooam
unt
cA
CH Buppeu5 a v a i c o l a t a t y p e vardabls, dnchuding
oat c double
'douae' : Doublt prcision loating poînt numbu
'oat' eingle ptdsioo oatng-point numbu.
fnt stqned 30-bit ínttqu
long 8fned 64-bit irutte
tlo- bit intthu.
Short:signtd Chaack
shing' A 8enuen
un C to psom operaHors on vauabu
avu ubed
EXprusions
Values. An eepiusion con
caLn be aa ei
aimple
neuob
produuce
and
and vasiab, or a Combin autfon oopeHCLtes opurane
vaues, a
t3 x
@q fnt my Reblt
in tastt uused to p pe
kpTUsions
8uch as athmHc,
OpeLauteis
8uppots vaious o peiates
toenuy opeatets.
logical,bituoist g
Compwúson
in C bu t, , * l ,7.,
-
ommonlycLsed
opeLatets
Some
5 A,9: ,chc
4,1,A
==, ==
>,<=<
au ndaumental Conceps
OveHau Vawuables and expHesions
usedl fn tOTitína
4 asu ettnsi vey
fn C pooammipg
Procpams
CH.
tht dtisíon statemuns usedin
Eist and explaîn
8tautemens that
N a i ng
Suppo Seveal decision -
bloch o Code
to Cecute a pauHoula
alloD thi poqHam
Outcoot a conolitfon.
bastd on th ot
8tottmenks ún
The decdsion -
Hakin9
Statemunt i ustd to ecicute a
statument The
i
poticulau oncltion ds tiue.Fhe
blos o cocle a
Sy tay!
Co ncdition)
SyntaX
th CcondlrtHen)
elst
blodqold.oiso oc
tt Col toececuue f Concli tiop is alst,
Suntax
CCondttora)
Jest
else-i Statmunt: else-&atment is utd do
Th
t t nsttd
multfpl Condlftfon.I t u s f m i l o to
unt aereqa udo
Stotement b u t mee Conciseu
Stntax'-
Cco noliion
e o o aoiigautqlduay argaadubd
ll Cocle to ececute Cond?Aon1 fs e n
useol in a Pogaun
data tupe d a .
that cah b con botd, a
that a voiable
the typt o valu
hat caun be peyermed on thou valu. In .
Operfos
butlt -in- dcto pe OVai lobu..
thee ale Sveou
ustd data C
the Common
nly ps t
pcgtan
ming
1.Value Types
Vaue t Oe utht basio olata tps n C# hat
hold a 8fnel vaue .
3ignigicant dliglts
*Doublet Rep>esents a doublu - pecdaf o n Loaing-
loaing- opoin
numbe.
Poirt number
floot epesuns a si ngle - peciaion ocing po
Repiesens
a
Cesuenc o unf Codle
S t i ng elemerts o thu 8ar
coUletion oL
ReptoS ents
a
Ava
data dup
a wse-deintd r ence Type
clays RLptueny
a tb . Value o
teet, t h e valu
v aluL ok
O
sult
'a is
is
nctementt o
assined
b by Value
b a c k to
t
a
b and dh conkxte
t a u m u n t 8 i n V a s u i o u s
eg
cocl that
ntqht oaust an ccception
n Lolg c
it OS
fni
Catch (Excupton e)
3. 'while Statement
3. 'do- ohile' Btatement (oqda ovio)dauos
4 o T loop: H OT Loop Std to execuue a block o Coc
aiocecd
cecd numb o t m s .t
onbies,
consi&s o 33 pasus
po
at ttu
ht loop t h i Condition ci checkLd
beginning o
ecLch tHatton, Qnd uthe inotement dacrermen
beginnig o
thu end o each dtuakon.
Atalernertts ececuuttd at
ib ustd t o erecute a block
. while lpop; A 9hf le loop
condlitioD iS tue. e
as a cetafn
O Cocle ab ong
Suntax
(o0
while (ConditHon)
Coole ttD be ececuttd
while(conclition) a llrolsoll
The code in uth oop us ececuted ust then thu
Condlf tion is checked I
toittate
t
S t s aulst
is túe ,
thloop Coni
the loon
the loop duMiDat
sing Sustem
Goa
n o)
Tetuen 1
elt
numbet", ); a
Gonbole.Oriteline("io} is SHong
a
else
numbet,n)
i not a 8Hong
Console.Oiteine
o
Conbole. Readkeyc);
Qiven aiau
wsing System
ClasProgram
heuo
intnuumRous
nt CI Tou9 Sum
=
SumCi]
Console. ori teline ($ Ro{1:1); {To