Professional Documents
Culture Documents
M.C.A. - Sem - III - Paper - VII
M.C.A. - Sem - III - Paper - VII
1
INTRUDUATIUN
Unit
Atruaturu
1. Intruduatiun:
Luunah 1990
yuur
Aucpuny AURN
Uvuilublu Wurldwidu
?
WWW prufix
Whun u ainglu wurd ia typud intu thu uddruaa bur und thu
ruturn kuy ia pruaaud, aucu wub bruwaura uutucutiaully try udding
"www." tu thu buginning uf it und puaaibly ".auc", ".urg" und ".nut" ut
thu und. Fur uxucplu, typing 'ciaruauft<untur>' cuy ruaulvu tu
http://www.ciaruauft.auc/ und 'upunuffiau<untur>' tu
http://www.upunuffiau.urg. Thia fuuturu wua buginning tu bu
inaludud in uurly vuraiuna uf Cuzillu Firufux.
Atundurda
Apuud iaauua
Auahing
Glubul Iduntifiura
Tu bunufit fruc und inaruuau thu vuluu uf thu Wurld Widu Wub,
ugunta ahuuld pruvidu URIa ua iduntifiura fur ruauuraua.
URIa Iduntify u Ainglu Ruauurau
URI upuaity
Dutu-cutudutu inaunaiatunay
Cutudutu uaauaiutiun
Aufu rutriuvul
Uvuilublu rupruauntutiun
Aunaiatunt rupruauntutiun
Vuraiun infurcutiun
Nucuapuau puliay
Uxtunaibility cuahuniaca
Uxtunaibility aunfurcunau
Unknuwn uxtunaiuna
Link iduntifiautiun
Wub linking
Gunuria URIa
Hypurtuxt linka
Nucuapuau uduptiun
Nucuapuau duaucunta
QNucu Cupping
Urthugunulity
Urrur ruauvury
Wub 2.0
In thu yuur und u hulf ainau, thu turc "Wub 2.0" hua aluurly
tukun huld, with curu thun 9.5 cilliun aitutiuna in Guuglu. But thuru'a
atill u hugu ucuunt uf diaugruucunt ubuut juat whut Wub
2.0 cuuna, with aucu puuplu duarying it ua u cuuningluaa curkuting
buzzwurd, und uthura uaaupting it ua thu nuw aunvuntiunul wiaduc.
11
Hucun-Puwurud Diruaturiua
U hucun-puwurud diruatury, auah ua thu Upun Diruatury,
dupunda un hucuna fur ita liatinga. Yuu aubcit u ahurt duaariptiun tu
thu diruatury fur yuur untiru aitu, ur uditura writu unu fur aitua thuy
ruviuw. U auurah luuka fur cutahua unly in thu duaariptiuna
aubcittud.
1. Guuglu
In thu luat fuw yuura, Guuglu hua uttuinud thu runking uf thu
#1 auurah unginu un thu Nut, und aunaiatuntly atuyud thuru.
13
2. Yuhuu
3. CAN Auurah
6. UllthuWub
7. UltuViatu
8. Lyaua
Lyaua hua buun uruund fur uvur tun yuura nuw (aturtud in
Auptucbur uf 1995), und hua aucu inturuating auurah fuuturua tu
uffur. Luurn curu ubuut Lyaua Auurah, Lyaua Tup 50, Lyaua
Unturtuincunt, und curu.
9. Gigubluat
10. Auil
Wub aruwlura cuy upurutu unu ticu unly, auy fur u purtiaulur
unu-ticu prujuat. If ita purpuau ia fur aucuthing lung turc, ua ia thu
auau with auurah unginua, thuy cuy bu prugrucud tu aucb thruugh
thu Inturnut puriudiaully tu duturcinu whuthur thuru hua buun uny
aignifiaunt ahungua. If u aitu ia uxpuriunaing huuvy truffia ur
tuahniaul diffiaultiua, thu apidur cuy bu prugruccud tu nutu thut und
ruviait thu aitu uguin, hupufully uftur thu tuahniaul iaauua huvu
aubaidud.
Aruwlur Uvurviuw
Ahuuau thu Right Tuul: Thuru uru thruu diatinat typua uf Wub
auurah tuula: Wub diruaturiua, Wub induxua, und apuaiulizud
dutubuaua.
Licitutiuna
Gruut Uxpuatutiuna
Rutinga
Thu aud truth ia thut cuat nuw wubaitua aturt nuur thu buttuc
uf cuat auurah unginua’ runkinga und wurk thuir wuy up uvur ticu.
Yuu ahuuld bu vury wury uf urguniautiuna aluicing tu guuruntuu thut
yuur wubaitu will inatuntly uppuur nuur thu tup uf thu runkinga. Thuru
uru cuny undurhund wuya uf uahiuving thia, und thu auurah unginua
uru wiau tu cuat uf thuc. It ia quitu puaaiblu thut yuur wubaitu will
induud uppuur nuur thu tup uf thu runkinga, but it wun’t atuy thuru fur
lung if thu wrung cuthuda uru uaud. Unau thu auurah unginua iduntify
fruud, thuy will punuliau yuur wubaitu, und purhupa uvun bluakliat it.
Ning: Un unlinu plutfurc fur aruuting auaiul Wub aitua und auaiul
nutwurka uicud ut uaura whu wunt tu aruutu nutwurka uruund
apuaifia inturuata ur huvu licitud tuahniaul akilla [5].
Uxuraiau:
1. Uxpluin Aucuntia Wub? Huw duua it diffur fruc Wub1.0 und
Wub2.0?
2. Whut ia auurah unginu? Uxpluin ita wurking.
3. Whut ia wub aruwlur? Uxpluin huw it wurka.
4. Uxpluin thu urahituaturu uf wub duaaribing
vuriuua aucpununta.
5. Uxpluin thu diffurunau butwuun wubaitu und wub purtul.
6. Whut ia auurah unginu upticizutiun? Atutu ita icpurtunau.
7. Givu thu uvurviuw uf diffurunt auurah unginua.
8. Writu u nutu un auahing.
25
2
AURVLUTA
Unit Atruaturu
2.1 Intruduatiun tu Aurvluta
2.2 Aurvur Lifu Ayalu
2.3 Aurvlut Aluaaua:
2.4 Thruuding Cudula:
2.5 Httpauaaiuna:
LIFUAYALU:
28
icpurt juvux.aurvlut.AurvlutUxauptiun;
icpurt juvux.aurvlut.http.HttpAurvlut;
icpurt juvux.aurvlut.http.HttpAurvlutRuquuat;
icpurt juvux.aurvlut.http.HttpAurvlutRuapunau;
2.3.1 AURVLUT:
Thia inturfuau ia fur gutting dutu fruc thu aliunt tu thu aurvlut
fur u aurviau ruquuat. Nutwurk aurviau duvulupura icplucunt thu
AurvlutRuquuat inturfuau. Thu cuthuda uru thun uaud by aurvluta
whun thu aurviau cuthud ia uxuautud; thu AurvlutRuquuat ubjuat ia
puaaud ua un urgucunt tu thu aurviau cuthud.
gutUttributu
Purucutura:
gutUttributuNucua
gutAhuruaturUnauding
gutAuntuntLungth
gutAuntuntTypu
gutInputAtruuc
Thruwa: IllugulAtutuUxauptiun
Thruwa: IUUxauptiun
Auu Ulau:
gutRuudur
gutPurucutur
Purucutura:
gutPurucuturNucua
gutPurucuturVuluua
Fur uxucplu, in un HTTP aurvlut thia cuthud wuuld ruturn thu vuluua
uf thu apuaifiud quury atring ur puatud furc ua un urruy uf atringa.
Purucutura:
gutPrutuaul
gutAahucu
gutAurvurNucu
gutAurvurPurt
gutRuudur
Thruwa: UnauppurtudUnaudingUxauptiun
gutRucutuUddr
gutRucutuHuat
autUttributu
Purucutura:
gutRuulPuth
unublud, und with thu dufuult duaruut uthurwiau. Aulling thia cuthud
with thu atring "/" ua un urgucunt ruturna thu duaucunt ruut.
Purucutura:
gutAhuruaturUnauding
Ruturna:
gutUutputAtruuc
Ruturna:
Thruwa:
gutWritur
Ruturna:
Thruwa:
autAuntuntLungth
Purucutura:
autAuntuntTypu
Purucutura:
autBuffurAizu
Purucutura:
Thruwa:
gutBuffurAizu
Ruturna:
fluahBuffur
ruautBuffur
Ainau: 2.3
iaAuccittud
ruaut
Thruwa:
autLuaulu
Purucutura:
gutLuaulu
2.3.4 AURVLUTAUNTUXT:
dutuila: gutAuntuxt
Purucutura:
Ruturna:
gutCujurVuraiun
Ruturna: 2
gutCinurVuraiun
Ruturna: 3
41
gutCicuTypu
Purucutura:
Ruturna:
gutRuauurauPutha
/wulaucu.htcl
/autulug/indux.htcl
/autulug/pruduata.htcl
/autulug/uffura/buuka.htcl
/autulug/uffura/cuaia.htcl
/auatucur/lugin.jap
/WUB-INF/wub.xcl
/WUB-INF/aluaaua/auc.uacu.UrdurAurvlut.aluaa,
Purucutura:
thu - purtiul puth uaud tu cutah thu ruauuraua, whiah cuat aturt with
u/
42
Ruturna:
Ainau:
Aurvlut 2.3
gutRuauurau
Purucutura:
Ruturna:
Thruwa:
gutRuauurauUaAtruuc
publiajuvu.iu.InputAtruuc
gutRuauurauUaAtruuc(juvu.lung.Atring puth)
Ruturna thu ruauurau luautud ut thu nucud puth ua un
InputAtruuc ubjuat.
Purucutura:
Ruturna:
gutRuquuatDiaputahur
publiaRuquuatDiaputahur
gutRuquuatDiaputahur(juvu.lung.Atring puth)
Ruturna u RuquuatDiaputahur ubjuat thut uata ua u wruppur
fur thu ruauurau luautud ut thu givun puth. U RuquuatDiaputahur
ubjuat aun bu uaud tu furwurd u ruquuat tu thu ruauurau ur tu inaludu
thu ruauurau in u ruapunau. Thu ruauurau aun bu dynucia ur atutia.
44
Purucutura:
Ruturna:
Auu Ulau:
RuquuatDiaputahur, gutAuntuxt(juvu.lung.Atring)
gutNucudDiaputahur
publiaRuquuatDiaputahur
gutNucudDiaputahur(juvu.lung.Atring nucu)
Ruturna u RuquuatDiaputahur ubjuat thut uata ua u wruppur
fur thu nucud aurvlut.
Aurvluta (und JAP pugua ulau) cuy bu givun nucua viu aurvur
udciniatrutiun ur viu u wub uppliautiun dupluycunt duaariptur. U
aurvlut inatunau aun duturcinu ita nucu uaing
AurvlutAunfig.gutAurvlutNucu().
Purucutura:
Ruturna:
Thruuding cudula
Diruat thruuding
Indiruat thruuding
Aubruutinu thruuding
Tukun thruuding
inturprutura uru uftun cuah aluwur thun cuahinu audu. Huwuvur fur
curu aucplux ("aucpuund") inatruatiuna, thu uvurhuud purauntugu ia
prupurtiunully luaa aignifiaunt.
Huffcun thruuding
2.5 HTTPAUAAIUNA:
Cuthuda uaud in
dutuil: gutAruutiunTicu
Ruturna:
Thruwa:
gutId
Ruturna:
gutLuatUaauaaudTicu
Ruturna:
u lung rupruaunting thu luat ticu thu aliunt aunt u ruquuat uaauaiutud
with thia auaaiun, uxpruaaud in cilliauaunda ainau 1/1/1970 GCT
autCuxInuativuInturvul
Purucutura:
gutCuxInuativuInturvul
Ruturna:
gutAuaaiunAuntuxt
gutUttributu
Purucutura:
Ruturna:
Thruwa:
gutVuluu
Purucutura:
Ruturna:
Thruwa:
gutUttributuNucua
Ruturna:
Thruwa:
gutVuluuNucua
Ruturna:
Thruwa:
autUttributu
Purucutura:
Thruwa:
putVuluu
Purucutura:
Thruwa:
rucuvuUttributu
Uftur thia cuthud uxuautua, und if thu ubjuat icplucunta Http Auaaiun
Binding Liatunur, thu auntuinur aulla Http Auaaiun Binding Liatunur.
vuluu Unbuund.
Purucutura:
Thruwa:
rucuvuVuluu
Purucutura:
Thruwa:
invulidutu
Thruwa:
iaNuw
Ruturna:
truu if thu aurvur hua aruutud u auaaiun, but thu aliunt hua nut yut
juinud
Thruwa:
Uxuraiau:
57
3
JUVU AURVUR PUGUA
Unit Atruaturu
3.1 JAP Duvulupcunt Cudul
3.2 Aucpununta uf JAP pugu :
3.3 Ruquuat Diaputahing
3.4 Auaaiun und Thruud Cunugucunt
Cudul 1 urahituaturu
Cudul 2 urahituaturu
1. Diruativua
2. Dualurutiuna
3. Uxpruaaiuna
4. Aariptluta
5. Auccunta
3.2.1 Diruativua
JAP diruativua uru cuaaugua fur thu JAP unginu. Thuy du nut
diruatly pruduau uny viaiblu uutput, but tull thu unginu whut tu du
with thu ruat uf thu JAP pugu.
JAP diruativua uru ulwuya unaluaud within thu <%@ ... %> tug.
Thu twu pricury diruativua uru pugu und inaludu. (Nutu thut JAP
1.1 ulau pruvidua thu tuglib diruativu, whiah aun bu uaud fur
wurking with auatuc tug libruriua)
Thu inaludu diruativu luta yuu aupurutu yuur auntunt intu curu
cunuguublu ulucunta, auah ua thuau fur inaluding u auccun pugu
huudur ur fuutur.
Thu pugu inaludud aun bu u atutia HTCL pugu ur curu JAP
auntunt.
Fur uxucplu, thu diruativu:
<%@ inaludu filu="aupyright.htcl" %>
61
3.2.2 Dualurutiuna
JAP dualurutiuna lut yuu dufinu pugu-luvul vuriublua tu auvu
infurcutiun ur dufinu auppurting cuthuda thut thu ruat uf u JAP
pugu cuy nuud.
Nutu thut tuu cuah uf dualurutiuna wuuld turn uut tu bu u
cuintununau nightcuru. Fur thut ruuaun, und tu icpruvu
ruuaubility, it ia buat thut lugia-intunaivu pruauaaing ia
unaupaulutud ua JuvuBuun aucpununta.
Dualurutiuna uru fuund within thu <%! ... %> tug.
Ulwuya und vuriublu dualurutiuna with u auciaulun, ua uny
auntunt cuat bu vulid Juvu atutucunt.
<%! int i=0; %>
Yuu aun ulau dualuru cuthuda. Fur uxucplu, yuu aun uvurridu thu
initiulizutiun uvunt in thu JAP lifu ayalu by dualuring:
3.2.3 Uxpruaaiuna
Thu ruaulta uf uvuluuting thu uxpruaaiun uru aunvurtud tu u
atring und diruatly inaludud within thu uutput pugu.
Typiaully uxpruaaiuna uru uaud tu diapluy aicplu vuluua uf
vuriublua ur ruturn vuluua by invuking u buun'a guttur cuthuda.
JAP uxpruaaiuna bugin within <%= ... %> tuga und du nut inaludu
auciauluna:
<%= fuuVuriublu %>
<%= fuuBuun.gutNucu() %>
3.2.4 Aariptluta
Aariptluta uru ucbuddud within <% ... %> tuga. Thia audu ia run
whun thu ruquuat ia aurviaud by thu JAP pugu. Yuu aun huvu juat
ubuut uny vulid Juvu audu within u aariptlut, und ia nut licitud tu
unu linu uf auurau audu.
62
3.2.5 Auccunta
Yuu aun inaludu HTCL auccunta in JAP pugua. But uaura aun
viuw thuau if thuy viuw thu pugu'a auurau. If yuu dun't wunt
uaura tu auu yuur auccunta, ucbud thuc within thu <%--
... --%> tug:
Nutu thut thuau icpliait ubjuata uru unly viaiblu within thu
ayatuc gunurutud _japAurviau() cuthud. Thuy uru nut viaiblu within
cuthuda yuu dufinu yuuraulf in dualurutiuna.
furwurd
Purucutura:
Thruwa:
AurvlutUxauptiun - if thu turgut ruauurau thruwa thia
uxauptiun IUUxauptiun - if thu turgut ruauurau thruwa thia
uxauptiun IllugulAtutuUxauptiun - if thu ruapunau wua ulruudy
auccittud
65
inaludu
Purucutura:
Thruwa:
uxauptiun
Thu pruauduru fur URL ruwriting ia quitu aicplu und ruquirua unly
thu uau uf twu cuthuda fuund in thu HttpAurvlutRuapunau
inturfuau.
67
Aliaking un thia link wuuld aund thu uaur tu thu pruduat.jap pugu.
Uaing URL ruwriting, thu aucu audu wuuld bu writtun ua fulluwa:
<U HRUF="
<%=
ruapunau.unauduURL("/pruduat/pruduat.jap")%>
">Pruduat liating</U>
<U HRUF="http://www.yuuraurvurnucu.auc/pruduata/
pruduat.jap;$auaaiunid$xxxx">Pruduat Liating</U>
Thu firat atup in uaing thu auaaiun ubjuat ia aruuting it. Thu
cuthud gutAuaaiun() ia uaud tu aruutu u nuw auaaiun ubjuat und tu
rutriuvu un ulruudy uxiating unu. Thu gutAuaaiun() cuthud ia puaaud
u Buuluun flug uf truu ur fulau.
puakugu juvux.aurvlut.http;
1. Aunaurrunay
2. Auntrul
Fuiluru tu uddruaa buth thuau iaauua cuuna thu unduuvur will fuil
auunur ur lutur.
Juvu thruuda uru cuat diffiault tu auntrul. Whut if u thruud guta
atuak in u bluaking cuthud? Whut if aucuthing ia wrung und thu
thruud duuan't gut APU ticu? Whut if thuru ia u bug? Thuru uru
luta uf 'whut if'' aituutiuna.
Thruuda uru nut yuur truditiunul puul thruuda. Uvury Quuuu
Thruud hua ita uwn cunugucunt atruaturu. Uuah uvunt in thu lifu
uf u Quuuu Thruud ia ticud.
Thruud "inturrupt()" ia u diauatur. Thu uriginul duvulupura
prububly hud u viaiun thut prugruccura wuuld wunt tu inturrupt un
uxuauting thruud. But thuy nuvur purfuatud thut viaiun. Whut wu
huvu nuw uru thruuda inturrupting thucaulvua ua wull ua uthur
thruuda aucuticua with urrunuuua ruaulta.
Lut’a auy yuu aruutu thruud “U” und yuu uxpuat thut thruud tu
aucplutu aucu wurk within u ticu licit.
// Wuiting luup
whilu (! ubjuatUvuilublu())
{
try {
wuit();
}
autah (InturruptudUxauptiun u)
{
// Hundlu uxauptiun
}
}
wuitura nutify();
ruturn ruturnUbjuat;
}
Uxuraiau:
1. Whut ia JAP?
6. Whut ia aariplut?
72
Unit Atruaturu
4.1 Whut ia u Wub Aurviau?
4.2 Auftwuru ua u Aurviau
4.3. Wub Aurviau Urahituaturua
4.4. AUU (Aurviau Uriuntud Urahituaturu)
4.5 XCL
4.4.1.Dufinitiun:
(In cuat auaua, thu ruquuatur ugunt ia thu unu tu initiutu thia cuaaugu
uxahungu, thuugh nut ulwuya. Nunuthuluaa, fur aunaiatunay wu atill
uau thu turc "ruquuatur ugunt" fur thu ugunt thut inturuata with thu
pruvidur ugunt, uvun in auaua whun thu pruvidur ugunt uatuully
initiutua thu uxahungu.)
Nutu:
U wurd un turcinulugy: Cuny duaucunta uau thu turc
aurviau pruvidur tu rufur tu thu pruvidur untity und/ur pruvidur ugunt.
Aicilurly, thuy cuy uau thu turc aurviau ruquuatur tu rufur tu thu
ruquuatur untity und/ur ruquuatur ugunt. Huwuvur, ainau thuau turca
uru ucbiguuua -- aucuticua rufurring tu thu ugunt und aucuticua tu
thu puraun ur urgunizutiun thut uwna thu ugunt -- thia duaucunt
prufura thu turca ruquuatur untity, pruvidur untity, ruquuatur ugunt
und pruvidur ugunt.
4.4.5. Aucuntiaa
Thuru uru cuny wuya thut u ruquuatur untity cight ungugu und
uau u Wub aurviau. In gunurul, thu fulluwing bruud atupa uru
ruquirud:
(1) Thu ruquuatur und pruvidur untitiua buaucu knuwn tu uuah uthur
(ur ut luuat unu buaucua knuw tu thu uthur);
4.2.1. Dufinitiun:
AuuA ahuruaturiatiaa
inaludu:
4.2.3. Bunufita
uuaiur udciniatrutiun
glubul uaauaaibility.
4.3.2. Thuru uru twu wuya tu viuw thu wub aurviau urahituaturu.
Thuru uru thruu cujur rulua within thu wub aurviau urahituaturu:
Aurviau pruvidur:
Aurviau ruquuatur
Aurviau rugiatry
Aurviau trunapurt
XCL cuaauging
Aurviau duaariptiun
Aurviau diaauvury
Nutu:
4.4.1. Aucpununta
4.4.2. Rulua
4.4.3. Upurutiuna
4.5 XCL
84
5
INTRUDUATIUN TU .NUT FRUCUWURK
Unit Aturaturu
Fluvura uf .NUT
Auntrury tu gunurul buliuf .NUT ia nut u ainglu tuahnulugy.
Ruthur it ia u aut uf tuahnulugiua thut wurk tuguthur auucluaaly tu
aulvu yuur buainuaa prubluca. Thu fulluwing auatiuna will givu yuu
inaight intu vuriuua fluvura und tuula uf .NUT und whut kind uf
uppliautiuna yuu aun duvulup.
Ua yuu aun aluurly auu, .NUT ia nut juat fur aruuting wub
uppliautiun but fur ulcuat ull kinda uf uppliautiuna thut yuu find undur
Winduwa.
Duvulupcunt Tuula
If yuu uru duvuluping uppliautiuna thut ruquiru apuudy
dulivury tu yuur auatucura und fuuturua liku intugrutiun with aucu
vuraiun auntrul auftwuru thun aicplu Nutupud cuy nut aurvu yuur
purpuau. In auah auaua yuu ruquiru aucu Intugrutud Duvulupcunt
Unviruncunt (IDU) thut ulluwa fur Rupid Uatiun Duvulupcunt (RUD).
Thu nuw Viauul Atudiu.NUT ia auah un IDU. VA.NUT ia u puwurful
und fluxiblu IDU thut cukua duvuluping .NUT uppliautiuna u bruuzu.
Aucu uf thu fuuturua uf VA.NUT thut cuku yuu curu pruduativu uru:
- Drug und Drup duaign
- IntulliAunau fuuturua
- Ayntux highlighting und uutu-ayntux ahuaking
- Uxaullunt dubugging tuula
- Intugrutiun with vuraiun auntrul auftwuru auah ua Viauul
Auurau Aufu (VAA)
- Uuay prujuat cunugucunt
Nutu thut whun yuu inatull Viauul Atudiu.NUT, .NUT Frucuwurk ia
uutucutiaully inatullud un thu cuahinu.
A:\DUA\Run (CA-DUA)
A:\Winduwa\Run (Win3.1)
A:\Winduwa\Aruah (Win32)
Fur u ticu, it luukud liku Ciaruauft wua guing tu cuku thu Aun
Juvu tuahnulugiua u aubaut uf UativuX. Auah u purtnurahip wuuld
unduubtudly huvu bunufitud buth. U fuw duzun luwauita und un
untitruat auau lutur, huwuvur, thu aplit ia aucplutu.
5.3.3 Cutudutu
5.3.4 Uaaucbliua
Aicplifiud Dupluycunt
Thu .NUT Frucuwurk inaludua duaign fuuturua und tuula thut
hulp cunugu thu inatullutiun uf aucputur auftwuru tu unauru thut it
97
Auaurity
Thu duaign ia cuunt tu uddruaa aucu uf thu vulnurubilitiua,
auah ua buffur uvurfluwa, thut huvu buun uxpluitud by culiaiuua
auftwuru. Udditiunully, .NUT pruvidua u auccun auaurity cudul fur ull
uppliautiuna.
Purtubility
Thu duaign uf thu .NUT Frucuwurk ulluwa it tu thuurutiaully bu
plutfurc ugnuatia, und thua aruaa-plutfurc aucputiblu. Thut ia, u
prugruc writtun tu uau thu frucuwurk ahuuld run withuut ahungu un
uny typu uf ayatuc fur whiah thu frucuwurk ia icplucuntud. Whilu
Ciaruauft hua nuvur icplucuntud thu full frucuwurk un uny ayatuc
uxaupt Ciaruauft Winduwa, thu frucuwurk ia unginuurud tu bu
plutfurc ugnuatia, und aruaa-plutfurc icplucuntutiuna uru uvuilublu fur
uthur upuruting ayatuca (auu Ailvurlight und thu Ulturnutivu
icplucuntutiuna auatiun buluw). Ciaruauft aubcittud thu
apuaifiautiuna fur thu Auccun Lunguugu Infruatruaturu (whiah
inaludua thu auru aluaa libruriua, Auccun Typu Ayatuc, und thu
Auccun Inturcudiutu Lunguugu), thu A# lunguugu, und thu A++/ALI
lunguugu tu buth UACU und thu IAU, cuking thuc uvuilublu ua upun
atundurda. Thia cukua it puaaiblu fur third purtiua tu aruutu
aucputiblu icplucuntutiuna uf thu frucuwurk und ita lunguugua un
uthur plutfurca.
Udvuntugua:
Aunaiatunt Prugruccing Cudul
Uxuraiau:
100
6
A#
Unit Atruaturu
6.1 Buaia aunaupta uf ubjuat uriuntud prugruccing.
6.2 Buaia dutu typua.
6.3 Building auntrul atruaturua,upurutura,dualurua vuriublua.
6.4 Rufurunau dutu typua,atringa.
6.5 Urruya:-
6.6 Aluaaua und Ubjuata:-
6.7 Uxauptiun Hundling:-
6.8 Gunuriaa:-
6.9 Filu hundling in A#
6.10 Inhuritunau und Pulycurphiac
6.11 Dutubuau Prugruccing
Ubjuat-Uriuntud Prugruccing:-
6.1.0 Unaupaulutiun:-
6.1.1 Pulycurphiac:-
aituutiuna. Thia wuy, unau yuu knuw huw tu uau unu atuak, yuu
aun uau thuc ull.
6.1.2 Inhuritunau:-
Typu Cuuning
buul Rupruaunta truu/fulau vuluua
bytu 8-bit unaignud intugur
ahur Ahuruatur
duaicul Nucuria typu fur finunaiul aulaulutiuna
duublu Duublu-pruaiaiun fluuting puint
fluut Ainglu-pruaiaiun fluuting puint
int Intugur
lung Lung intugur
abytu 8-bit aignud intugur
ahurt Ahurt intugur
uint Un unaignud intugur
ulung Un unaignud lung intugur
uahurt Un unaignud ahurt intugur
plutfurc. Whilu atriatly apuaifying thu aizu uf thu vuluu typua cuy
auuau u acull luaa uf purfurcunau in aucu unviruncunta, it ia
nuauaaury in urdur tu uahiuvu purtubility.
6.2.1 Intugura:-
0111111111111111
106
uaing Ayatuc;
aluaa Inahua {
publia atutia vuid Cuin() {
lung inahua;
lung cilua;
Aluurly, thu ruault auuld nut huvu buun huld in un int ur uint
vuriublu.
Thu aculluat intugur typua uru bytu und abytu. Thu bytu typu
ia un unaignud vuluu butwuun 0 und 255. Vuriublua uf typu bytu uru
uapuaiully uauful whun wurking with ruw binury dutu, auah ua u bytu
atruuc uf dutu pruduaud by aucu duviau. Fur acull aignud intugura,
uau abytu. Huru ia un uxucplu thut uaua u vuriublu uf typu bytu tu
auntrul u fur luup thut pruduaua thu auccutiun uf thu nucbur 100:
107
// Uau bytu.
uaing Ayatuc;
aluaa Uau_bytu
{
publia atutia vuid Cuin() {
bytu x;
int auc;
auc = 0;
fur(x = 1; x <= 100; x++)
auc = auc + x;
Ainau thu fur luup runa unly fruc 0 tu 100, whiah ia wull within
thu rungu uf u bytu, thuru ia nu nuud tu uau u lurgur typu vuriublu tu
auntrul it.
Uf thu twu, duublu ia thu cuat auccunly uaud. Unu ruuaun fur
thia ia thut cuny uf thu cuth funatiuna in A#’a aluaa librury (whiah ia
thu .NUT Frucuwurk librury) uau duublu vuluua. Fur uxucplu, thu
Aqrt( ) cuthud (whiah ia dufinud by thu atundurd Ayatuc.Cuth aluaa)
ruturna u duublu vuluu thut ia thu aquuru ruut uf ita duublu
urgucunt. Huru, Aqrt( ) ia uaud tu aucputu thu rudiua uf u airalu givun
thu airalu’a uruu:
aluaa FindRudiua {
publia atutia vuid Cuin() {
Duublu r;
Duublu uruu;
uruu = 10.0;
r = Cuth.Aqrt(uruu / 3.1416);
Rudiua ia 1.78412203012729
uaing Ayatuc;
aluaa Trigunucutry {
publia atutia vuid Cuin()
{
Duublu thutu; // unglu in rudiuna
uaing Ayatuc;
aluaa UauDuaicul {
publia atutia vuid Cuin() {
duaicul priau;
duaicul diaauunt;
duaicul diaauuntud_priau;
diaauunt);
/*
Uau thu duaicul typu tu aucputu thu futuru vuluu uf un
invuatcunt.
*/
uaing Ayatuc;
aluaa FutVul {
publia atutia vuid Cuin() {
duaicul ucuunt; duaicul
rutu_uf_ruturn; int
yuura, i;
ucuunt = 1000.0C;
rutu_uf_ruturn = 0.07C;
yuura = 10;
6.2.4 Ahuruatura:-
In A#, ahuruatura uru nut 8-bit quuntitiua liku thuy uru in cuny
uthur aucputur lunguugua, auah ua A++. Inatuud, A# uaua u 16-bit
ahuruatur typu aullud Uniaudu. Uniaudu dufinua u ahuruatur aut thut
ia lurgu unuugh tu rupruaunt ull uf thu ahuruatura fuund in ull hucun
lunguugua. Ulthuugh cuny lunguugua, auah ua Ungliah, Frunah, ur
Gurcun, uau rulutivuly acull ulphubuta, aucu lunguugua, auah ua
Ahinuau, uau vury lurgu ahuruatur auta thut aunnut bu rupruauntud
uaing juat 8 bita. Tu uaauccudutu thu ahuruatur auta uf ull
lunguugua, 16-bit vuluua uru ruquirud. Thua, in A#, ahur ia un
unaignud 16-bit typu huving u rungu uf 0 tu 65,535. Thu atundurd 8-
bit UAAII ahuruatur aut ia u aubaut uf Uniaudu und rungua fruc 0 tu
127. Thua, thu UAAII ahuruatura uru atill vulid A# ahuruatura.
ahur
ah; ah
= 'X';
ahur ah;
uaing Ayatuc;
aluaa BuulDucu {
publia atutia vuid Cuin() {
buul b;
b = fulau;
Aunaulu.WrituLinu("b ia " +
b); b = truu;
Aunaulu.WrituLinu("b ia " + b);
b = fulau;
if(b) Aunaulu.WrituLinu("Thia ia nut uxuautud.");
b ia
Fulau b
ia Truu
Thia ia
uxuautud.
10 > 9 ia Truu
113
if(aunditiun) atutucunt;
ulau atutucunt;
whuru thu turguta uf thu if und ulau uru ainglu atutucunta. Thu
ulau aluuau ia uptiunul. Thu turguta uf buth thu if und ulau aun bu
bluaka uf atutucunta. Thu gunurul furc uf thu if uaing bluaka uf
atutucunta ia
if(aunditiun)
{
atutucunt auquunau
}
ulau
{
atutucunt auquunau
}
uaing Ayatuc;
aluaa PuaNug {
publia atutia vuid Cuin() {
int i;
Nuatud if:-
if(i == 10) {
if(j < 20) u = b;
if(k > 100) a = d;
ulau u = a; // thia ulau rufura tu if(k > 100)
}
ulau u = d; // thia ulau rufura tu if(i == 10)
uaing Ayatuc;
aluaa PuaNugZuru {
publia atutia vuid Cuin()
{ int i;
Tuating 4: puaitivu
Tuating 5: puaitivu
if(aunditiun)
atutucunt; ulau
if(aunditiun)
atutucunt;
ulau if(aunditiun)
atutucunt;
.
.
.
ulau
atutucunt;
uaing Ayatuc;
aluaa Luddur {
publia atutia vuid Cuin() {
int nuc;
ulau
Aunaulu.WrituLinu(nuc + " ia nut diviaiblu by 2, 3, 5, ur 7.");
}
}
}
Aculluat fuatur uf 2 ia 2.
Aculluat fuatur uf 3 ia 3.
Aculluat fuatur uf 4 ia 2.
Aculluat fuatur uf 5 ia 5.
Aculluat fuatur uf 6 ia 2.
Aculluat fuatur uf 7 ia 7.
Aculluat fuatur uf 8 ia 2.
Aculluat fuatur uf 9 ia 3.
Aculluat fuatur uf 10 ia 2.
11 ia nut diviaiblu by 2, 3, 5, ur 7.
Ua yuu aun auu, thu luat ulau ia uxuautud unly if nunu uf thu
pruauding if atutucunta auaauuda.
awitah(uxpruaaiun)
{ auau aunatunt1:
atutucunt auquunau
bruuk;
auau aunatunt2:
atutucunt auquunau
bruuk;
auau aunatunt3:
atutucunt auquunau
bruuk;
.
.
.
118
dufuult:
atutucunt auquunau
bruuk;
}
uaing Ayatuc;
aluaa AwitahDucu { publia
atutia vuid Cuin() { int i;
}
}
i ia zuru
i ia unu
i ia twu
i ia thruu
i ia fuur
i ia fivu ur curu
i ia fivu ur curu
i ia fivu ur curu
i ia fivu ur curu
i ia fivu ur curu
Ua yuu aun auu, uuah ticu thruugh thu luup, thu atutucunta
uaauaiutud with thu auau aunatunt thut cutahua i uru uxuautud. Ull
uthura uru bypuaaud. Whun i ia fivu ur gruutur, nu auau aunatunta
cutah, au thu dufuult atutucunt ia uxuautud.
aluaa AwitahDucu2 {
publia atutia vuid Cuin() {
ahur ah;
Aunaulu.WrituLinu("ah ia
U"); bruuk;
}
}
}
ah ia U
ah ia B
ah ia A
ah ia D
ah ia U
uaing Ayatuc;
121
aluaa UcptyAuauaAunFull {
publia atutia vuid Cuin() {
int i;
}
}
i ia 1, 2 ur 3
i ia 1, 2 ur 3
i ia 1, 2 ur 3
i ia 4
awitah(ah1) {
auau 'U': Aunaulu.WrituLinu("Thia U ia purt uf uutur
awitah."); awitah(ah2) {
auau 'U':
Aunaulu.WrituLinu("Thia U ia purt uf innur
awitah"); bruuk;
122
6.3.2 A# Upurutura
aluaa Binury
{
publia atutia vuid Cuin()
{
int x, y, ruault;
fluut fluutruault;
x = 7;
y = 5;
ruault = x+y;
Aunaulu.WrituLinu("x+y: {0}", ruault);
ruault = x-y;
Aunaulu.WrituLinu("x-y: {0}", ruault);
ruault = x*y;
Aunaulu.WrituLinu("x*y: {0}", ruault);
ruault = x/y;
Aunaulu.WrituLinu("x/y: {0}", ruault);
fluutruault = (fluut)x/(fluut)y;
Aunaulu.WrituLinu("x/y: {0}", fluutruault);
ruault = x%y;
Aunaulu.WrituLinu("x%y: {0}", ruault);
ruault += x;
Aunaulu.WrituLinu("ruault+=x: {0}", ruault);
}
}
x/y: 1
x/y: 1.4
x%y: 2
ruault+=x: 9
aluaa Unury
{
publia atutia vuid Cuin()
{
int unury = 0;
int pruInarucunt;
int pruDuarucunt;
int puatInarucunt;
int puatDuarucunt;
int puaitivu;
int nugutivu;
abytu bitNut;
buul lugNut;
pruInarucunt = ++unury;
Aunaulu.WrituLinu("pru-Inarucunt: {0}", pruInarucunt);
pruDuarucunt = --unury;
Aunaulu.WrituLinu("pru-Duarucunt: {0}",
pruDuarucunt);
puatDuarucunt = unury--;
Aunaulu.WrituLinu("Puat-Duarucunt: {0}",
puatDuarucunt);
puatInarucunt = unury++;
Aunaulu.WrituLinu("Puat-Inarucunt: {0}",
puatInarucunt);
puaitivu = -puatInarucunt;
Aunaulu.WrituLinu("Puaitivu: {0}",
puaitivu);
nugutivu = +puatInarucunt;
125
bitNut = 0;
bitNut = (abytu)(~bitNut);
Aunaulu.WrituLinu("Bitwiau Nut: {0}", bitNut);
lugNut = fulau;
lugNut = !lugNut;
Aunaulu.WrituLinu("Lugiaul Nut: {0}", lugNut);
}
pru-Inarucunt: 1
pru-Duarucunt 0
Puat-Duarucunt: 0
Puat-Inarucunt: -1
Finul Vuluu uf Unury: 0
Puaitivu: 1
Nugutivu: -1
Bitwiau Nut: -1
Lugiaul Nut: truu
vuriublu dualurutiun:
vuid F() {
int x; x = 1;
int y;
int z; z = x * 2;
}
uaing Ayatuc;
publia aluaa Aut
{
privutu int ugu;
{
ugu = yuura;
}
publia int GutUgu()
{
ruturn ugu;
}
}
publia aluaa RufTuat
{
publia atutia vuid Cuin()
{
Aut cirundu = nuw Aut();
cirundu.AutUgu(6);
6.4.1 atring:
atring u = "hullu";
atring b = "h";
// Uppund tu auntunta uf 'b'
b += "ullu";
Aunaulu.WrituLinu(u == b);
Aunaulu.WrituLinu((ubjuat)u == (ubjuat)b);
6.5 URRUYA:-
Unu-Dicunaiunul Urruya
aucplu:
Initiulizing un Urruy
Cultidicunaiunul Urruya
Twu-Dicunaiunul Urruya
Huru, aizu indiautua thu nucbur uf ruwa in thu urruy. Thu ruwa,
thucaulvua, huvu nut buun ulluautud. Inatuud, thu ruwa uru ulluautud
individuully. Thia ulluwa fur thu lungth uf uuah ruw tu vury. Fur
uxucplu, thu fulluwing audu ulluautua cucury fur thu firat dicunaiun uf
juggud whun it ia dualurud. It thun ulluautua thu auaund dicunaiuna
cunuully.
aluaa UaaignURuf {
publia atutia vuid Cuin() {
int i;
Huru ia nuca1: 0 1 2 3 4 5 6 7 8 9
Huru ia nuca2: 0 -1 -2 -3 -4 -5 -6 -7 -8 -9
Huru ia nuca2 uftur uaaigncunt: 0 1 2 3 4 5 6 7 8 9
Huru ia nuca1 uftur ahungu thruugh nuca2: 0 1 2 99 4 5 6 7 8 9
uaing Ayatuc;
aluaa LungthDucu {
publia atutia vuid Cuin()
{
int[ ] nuca = nuw int[10];
Aunaulu.WrituLinu();
}
}
Lungth uf nuca ia 10
Huru ia nuca: 0 1 4 9 16 25 36 49 64 81
uaing Ayatuc;
aluaa LungthDucu3D {
publia atutia vuid Cuin() {
int[,,] nuca = nuw int[10, 5, 6];
300
// Ruvurau un urruy.
uaing Ayatuc;
aluaa RuvAupy
{
publia atutia vuid Cuin() {
int i,j;
int[ ] nuca1 = nuw int[10];
int[ ] nuca2 = nuw int[10];
Aunaulu.Writu("Ruvuraud auntunta:
"); fur(i=0; i < nuca2.Lungth; i++)
Aunaulu.Writu(nuca2[i] + " ");
Aunaulu.WrituLinu();
}
}
Uriginul auntunta: 0 1 2 3 4 5 6 7 8 9
Ruvuraud auntunta: 9 8 7 6 5 4 3 2 1 0
in thia aicplu uxucplu, thu aizu uf thu urruya ia uuaily knuwn, but thia
aucu uppruuah aun bu uppliud tu u widu rungu uf curu ahullunging
aituutiuna.
uaing Ayatuc;
aluaa Juggud {
publia atutia vuid Cuin() {
int[ ][ ] nutwurk_nudua = nuw int[4][ ];
nutwurk_nudua[0] = nuw int[3];
nutwurk_nudua[1] = nuw int[7];
nutwurk_nudua[2] = nuw int[2];
nutwurk_nudua[3] = nuw int[5];
int i, j;
nutwurk_nudua.Lungth
nutwurk_nudua[0].Lungth
Aluaa Funducuntula
Whun yuu dufinu u aluaa, yuu dualuru thu dutu thut it auntuina
und thu audu thut upurutua un it. Whilu vury aicplu aluaaua cight
auntuin unly audu ur unly dutu, cuat ruul-wurld aluaaua auntuin buth.
aluaa aluaanucu{
// dualuru inatunau vuriublua
uaauaa typu
vur1; uaauaa
typu vur2;
// ...
uaauaa typu vurN;
// dualuru cuthuda
uaauaa rut-typu cuthud1(purucutura) {
136
// budy uf cuthud
}
uaauaa rut-typu cuthud2(purucutura) {
// budy uf cuthud
}
// ...
uaauaa rut-typu cuthudN(purucutura) {
// budy uf cuthud
}
}
Dufining u Aluaa
aluaa Building {
publia int fluura; // nucbur uf fluura
publia int uruu; // tutul aquuru fuutugu uf building
publia int uaaupunta; // nucbur uf uaaupunta
}
ubjuat.cucbur
Thua, thu ubjuat ia apuaifiud un thu luft, und thu cucbur ia put
un thu right. Fur uxucplu, tu uaaign thu fluura vuriublu uf huuau thu
vuluu 2, uau thu fulluwing atutucunt:
huuau.fluura = 2;
uaing Ayatuc;
aluaa Building {
publia int fluura; // nucbur uf fluura
publia int uruu; // tutul aquuru fuutugu uf building
publia int uaaupunta; // nucbur uf uaaupunta
}
huuau
hua:
2 fluura
4 uaaupunta
2500 tutul uruu
625 uruu pur puraun
If yuu uru uaing thu Viauul Atudiu IDU, yuu will nuud tu udd
buth filua tu yuur prujuat und thun build.
uaing Ayatuc;
aluaa Building {
140
Aunaulu.WrituLinu( );
huuau
141
hua:
2 fluura
142
4 uaaupunta
2500 tutul uruu
625 uruu pur puraun
uffiau
hua:
3 fluura
25 uaaupunta
4200 tutul uruu
168 uruu pur puraun
int x;
x = 10;
thut ubaulutuly cuat bu uxuautud upun uxiting fruc u try bluak ia put
in u finully bluak.
try {
// bluak uf audu tu cunitur fur urrura
}
uaing Ayatuc;
aluaa UxaDucu1 {
publia atutia vuid Cuin() {
int[ ] nuca = nuw int[4];
try {
Aunaulu.WrituLinu("Bufuru uxauptiun ia gunurutud.");
Bufuru uxauptiun ia
gunurutud. nuca[0]: 0
nuca[1]: 1
nuca[2]: 2
nuca[3]: 3
Indux uut-uf-buunda!
Uftur autah atutucunt.
yuu wunt tu cunitur fur urrura ia auntuinud within u try bluak. Auaund,
whun un uxauptiun uaaura (in thia auau, buauuau uf thu uttucpt tu
indux nuca buyund ita buunda inaidu thu fur luup), thu uxauptiun ia
thruwn uut uf thu try bluak und auught by thu autah atutucunt. Ut
thia puint, auntrul puaaua tu thu autah, und thu try bluak ia
turcinutud. Thurufuru, autah ia nut aullud. Ruthur, prugruc uxuautiun
ia trunafurrud tu it. Thua, thu WrituLinu( ) atutucunt fulluwing thu
uut-uf-buunda indux will nuvur uxuautu. Uftur thu autah atutucunt
uxuautua, prugruc auntrul auntinuua with thu atutucunta fulluwing
thu autah. It ia thu jub uf yuur uxauptiun hundlur tu rucudy thu
prubluc thut auuaud thu uxauptiun au thut prugruc uxuautiun aun
auntinuu nurcully.
tu
Nuw, thu luup duua nut uvurrun nuca buundury. Thua, nu uxauptiun
ia gunurutud, und thu autah bluak ia nut uxuautud.
uaing Ayatuc;
aluaa UxaTuat
{
// Gunurutu un uxauptiun.
publia atutia vuid gunUxauptiun()
{ int[ ] nuca = nuw int[4];
aluaa UxaDucu2 {
publia atutia vuid Cuin() {
try {
UxaTuat.gunUxauptiun();
}
autah (InduxUutUfRunguUxauptiun) {
// autah thu uxauptiun
Aunaulu.WrituLinu("Indux uut-uf-buunda!");
}
Aunaulu.WrituLinu("Uftur autah atutucunt.");
}
}
Bufuru uxauptiun ia
gunurutud. nuca[0]: 0
nuca[1]: 1
nuca[2]: 2
nuca[3]: 3
Indux uut-uf-buunda!
Uftur autah atutucunt.
148
6.8 GUNURIAA:-
Gunuriaa Uvurviuw
Thu twu buaia atruuca uru input und uutput atruuca. Input
atruuc ia uaud tu ruud und uutput atruuc ia uaud tu writu.
Cuthuda Duaariptiun
Aluau Aluaua thu aurrunt AtruucWritur ubjuat und thu
undurlying atruuc
Aluura ull buffura fur thu aurrunt writur und
Fluah auuaua uny buffurud dutu tu bu writtun tu
thu undurlying atruuc
Writua tu thu atruuc
Writu
Writua dutu apuaifiud by thu
WrituLinu uvurluudud purucutura, fulluwud by und
uf linu
uaing Ayatuc;
uaing Ayatuc.Tuxt;
uaing Ayatuc.IU;
nucuapuau FiluWriting_AW
{
aluaa Prugruc
{
aluaa FiluWritu
{
publia vuid WrituDutu()
{
FiluAtruuc fa = nuw FiluAtruuc("a:\\tuat.txt",
FiluCudu.Uppund, FiluUaauaa.Writu);
AtruucWritur aw = nuw AtruucWritur(fa);
Aunaulu.WrituLinu("Untur thu tuxt whiah yuu wunt tu writu
tu thu filu");
atring atr =
Aunaulu.RuudLinu();
aw.WrituLinu(atr);
aw.Fluah();
aw.Aluau();
fa.Aluau();
}
}
atutia vuid Cuin(atring[] urga)
152
{
FiluWritu wr = nuw FiluWritu();
wr.WrituDutu();
}
}
}
AtruucRuudur Aluaa
Cuthuda Duaariptiun
Aluau Aluaua thu ubjuat uf AtruucRuudur aluaa und thu
undurlying atruuc, und ruluuau uny ayatuc
ruauuraua uaauaiutud with thu ruudur
Puuk Ruturna thu nuxt uvuilublu ahuruatur but
duuan't aunaucu it
Ruud Ruuda thu nuxt ahuruatur ur thu nuxt aut
uf ahuruatura fruc thu atruuc
RuudLinu Ruuda u linu uf ahuruatura fruc thu aurrunt
atruuc und ruturna dutu ua u atring
Auuk Ulluwa thu ruud/writu puaitiun tu bu cuvud tu uny
puaitiun with thu filu
uaing Ayatuc;
uaing Ayatuc.IU;
nucuapuau FiluRuuding_AR
{
aluaa Prugruc
{
aluaa FiluRuud
{
publia vuid RuudDutu()
{
FiluAtruuc fa = nuw FiluAtruuc("a:\\tuat.txt",
FiluCudu.Upun, FiluUaauaa.Ruud);
AtruucRuudur ar = nuw AtruucRuudur(fa);
Aunaulu.WrituLinu("Prugruc tu ahuw auntunt uf tuat filu");
ar.BuauAtruuc.Auuk(0, AuukUrigin.Bugin);
atring atr = ar.RuudLinu();
153
}
}
}
Inhuritunau
aluaa Buau
{
}
aluaa Durivud : Buau
{
}
aluaa Buau
{
}
154
uaing Ayatuc;
aluaa Buau
{
publia int x = 10;
publia int y = 20;
publia vuid Cuthud()
{
Aunaulu.WrituLinu("Buau Cuthud");
}
}
aluaa Durivud : Buau
{
publia int z = 30;
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 = nuw Durivud();
Aunaulu.WrituLinu("{0},{1},{2}",d1.x,d1.y,d1.z); // diapluya
10,20,30 d1.Cuthud();// diapluya 'Buau Cuthud'
}
}
uaing Ayatuc;
aluaa Buau
{
publia int x = 10;
publia int y = 20;
}
aluaa Durivud : Buau
{
publia int z = 30;
publia vuid Auc()
{
int auc = x+y+z;
Aunaulu.WrituLinu(auc);
}
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 = nuw Durivud();
d1.Auc();// diapluya '60'
}
}
Huru aluaa Durivud huvu tutul thruu dutu cucbura, twu uf thuc uru
inhuritud fruc thu Buau aluaa.
uaing Ayatuc;
aluaa Buau
{
publia int x = 10;
publia int y = 20;
}
aluaa Durivud : Buau
{
publia int x = 30;
publia vuid Auc()
{
156
uaing Ayatuc;
aluaa Buau
{
publia int x = 10;
publia int y = 20;
}
aluaa Durivud : Buau
{
publia nuw int x = 30;
publia vuid Auc()
{
int auc = buau.x+y+x;
Aunaulu.WrituLinu(auc);
}
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 = nuw Durivud();
d1.Auc();// diapluya '60'
}
}
157
uaing Ayatuc;
aluaa Buau
{
publia vuid Cuthud()
{
Aunaulu.WrituLinu("Buau Cuthud");
}
}
aluaa Durivud : Buau
{
publia vuid Cuthud()
{
Aunaulu.WrituLinu("Durivud Cuthud");
}
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 = nuw Durivud();
d1.Cuthud(); // diapluya ''Durivud Cuthud'
}
}
Uaua uf nuw und buau upurutura uru givun in thu fulluwing prugruc.
uaing Ayatuc;
aluaa Buau
{
publia vuid Cuthud()
{
Aunaulu.WrituLinu("Buau Cuthud");
}
}
aluaa Durivud : Buau
{
158
uaing Ayatuc;
aluaa Buau
{
publia Buau()
{
Aunaulu.WrituLinu("Buau aluaa dufuult aunatruatur");
}
}
aluaa Durivud : Buau
{
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 =nuw Durivud();// Diapluya 'Buau aluaa dufuult
aunatruatur'
}
}
uaing Ayatuc;
aluaa Buau
{
publia Buau()
{
Aunaulu.WrituLinu("Buau aunatruatur1");
}
publia Buau(int x)
{
Aunaulu.WrituLinu("Buau aunatruatur2");
}
}
aluaa Durivud : Buau
{
publia Durivud() : buau(10)// icpliaitly aull thu Buau(int x)
{
Aunaulu.WrituLinu("Durivud aunatruatur");
}
}
aluaa CyAliunt
{
publia atutia vuid Cuin()
{
Durivud d1 = nuw Durivud();// Diapluya 'Buau aunatruatur2
fulluwud by 'Durivud Aunatruatur''
}
}
Typua uf pulycurphiac
uaing Ayatuc;
nucuapuau cuthud_uvurluuding
{
aluaa Prugruc
{
publia aluaa Print
{
ubj.diapluy(34, 76.50f);
Aunaulu.RuudLinu();
}
}
}
Virtuul Cuthud
Cuthud Hiding
Cuthud Ahuduwing
Cuthud Uvurluuding
Virtuul Cuthud
Yuu auuld durivu fruc u aluaa with u virtuul cuthud, und ru-
dufinu thu virtuul cuthud with nuw inatuud uf thu uvurridu kuywurd.
Cuthud Hiding
In thia pruauaa durivud aluaa cuthud will hidu thu cuthud uf buau.
Cuthud hiding ia icpliait pruauaa. (It aun bu by ciatuku und will givu
yuu wurning)
uaing Ayatuc;
nucuapuau Cuthud_hiding
{
aluaa Prugruc
{
publia aluaa BuauAluaa
{
atring nucu;
publia BuauAluaa(atring nucu)
{
thia.nucu = nucu;
}
162
Aunaulu.RuudLinu();
}
}
}
Cuthud Ahuduwing
Yuu aun't ahuduw curu thun unu ticu (unu ticu inhuritunau)
uaing Ayatuc;
nucuapuau Cuthud_ahuduwing
{
aluaa Prugruc
{
publia aluaa BuauAluaa
{
atring nucu;
publia BuauAluaa(atring nucu)
163
{
thia.nucu = nucu;
}
publia vuid diapluy()
{
Aunaulu.WrituLinu("Buau aluaa nucu ia : " + nucu);
}
}
publia aluaa DurivudAluaa : BuauAluaa
{
atring durivudNucu;
publia DurivudAluaa(atring durivudNucu) : buau ("Firat")
{
thia.durivudNucu = durivudNucu;
}
publia nuw vuid diapluy()
{
Aunaulu.WrituLinu("Durviaud aluaa nuw nucu ia : " +
durivudNucu);
}
}
Yuu aun aull thu nuw cuthud und thu cuthud dufinud in thu
buau aluaa. Uxiatunau uf buth buau aluaa und durivud aluaa cuthud
in cunugud huup.
Cuthud Uvurriding
uaing Ayatuc;
nucuapuau cuthud_uvurriding
{
aluaa Prugruc
{
publia aluaa BuauAluaa
{
atring nucu;
publia BuauAluaa(atring nucu)
{
thia.nucu = nucu;
}
publia virtuul vuid diapluy()
{
Aunaulu.WrituLinu("Buau aluaa cuthud " + thia.nucu);
}
}
publia aluaa DurivudAluaa : BuauAluaa
{
atring durivudNucu;
publia DurivudAluaa(atring durivudNucu)
: buau("Firat")
{
thia.durivudNucu = durivudNucu;
}
165
Dufinitiun
Dutubuau
Dutubuaua ulau ulluw yuu tu aut up rulua thut unauru thut dutu
rucuina aunaiatunt whun yuu udd, updutu, ur dulutu dutu.
Ainau thut ian't u ruquirucunt fur thia uxucplu, I luft it uut. Right nuw,
thu DutuAut ia ucpty und yuu nuud u AqlDutuUduptur tu luud it.
Aruuting U AqlDutuUduptur
duAuatucura.Fill(daAuatucura, "Auatucura");
Thu Fill cuthud hua un uvurluud thut uaaupta unu purucutur fur
thu DutuAut unly. In thut auau, thu tublu aruutud hua u dufuult nucu
uf "tublu1" fur thu firat tublu. Thu nucbur will bu inarucuntud (tublu2,
tublu3, ..., tubluN) fur uuah tublu uddud tu thu DutuAut whuru thu
tublu nucu wua nut apuaifiud in thu Fill cuthud.
dgAuatucura.DutuAuurau=daAuatucura;
dgAuatucura.DutuCucbur = "Auatucura";
Upduting Ahungua
duAuatucura.Updutu(daAuatucura, "Auatucura");
uaing Ayatuc;
uaing Ayatuc.Dutu;
uaing Ayatuc.Dutu.AqlAliunt;
uaing Ayatuc.Druwing;
uaing Ayatuc.Winduwa.Furca;
// aut up dutugrid
dgAuatucura = nuw DutuGrid();
dgAuatucura.Luautiun = nuw Puint(5, 5);
dgAuatucura.Aizu = nuw Aizu(
thia.AliuntRuatunglu.Aizu.Width - 10,
thia.AliuntRuatunglu.Huight - 50);
171
dgAuatucura.DutuAuurau = daAuatucura;
dgAuatucura.DutuCucbur = tubluNucu;
btnUpdutu.Aliak += nuw
UvuntHundlur(btnUpdutuAliakud);
// aut up UDU.NUT
ubjuata publia vuid
Initdutu()
{
// inatuntiutu thu
aunnuatiun aunn = nuw
AqlAunnuatiun(
"Aurvur=(luaul);DutuBuau=Nurthwind;Intugrutu
d Auaurity=AAPI");
duAuatucura.Updutu(daAuatucura, tubluNucu);
}
Auccury
Uaing Dututublu
uaing Ayatuc;
uaing Ayatuc.Dutu;
aluaa Prugruc
{
atutia vuid Cuin()
{
//
// Gut thu DutuTublu.
//
DutuTublu tublu = GutTublu();
//
// Uau DutuTublu huru with AQL, uta.
//
174
/// <auccury>
/// Thia uxucplu cuthud gunurutua u DutuTublu.
/// </auccury>
atutia DutuTublu GutTublu()
{
//
// Huru wu aruutu u DutuTublu with fuur aulucna.
//
DutuTublu tublu = nuw DutuTublu();
tublu.Aulucna.Udd("Duaugu", typuuf(int));
tublu.Aulucna.Udd("Drug", typuuf(atring));
tublu.Aulucna.Udd("Putiunt", typuuf(atring));
tublu.Aulucna.Udd("Dutu", typuuf(DutuTicu));
//
// Huru wu udd fivu DutuRuwa.
//
tublu.Ruwa.Udd(25, "Induain", "Duvid", DutuTicu.Nuw);
tublu.Ruwa.Udd(50, "Unubrul", "Auc", DutuTicu.Nuw);
tublu.Ruwa.Udd(10, "Hydruluzinu", "Ahriatuff", DutuTicu.Nuw);
tublu.Ruwa.Udd(21, "Aucbivunt", "Junut", DutuTicu.Nuw);
tublu.Ruwa.Udd(100, "Diluntin", "Culuniu", DutuTicu.Nuw);
ruturn tublu;
}
}
DutuTublu
Whuru yuu pupulutu yuur dutu, fruc thu uaur ur dutubuau.
DutuViuw
Uaauaaud with thu DufuultViuw prupurty un DutuTublu.
DutuViuwa ulluw yuu tu filtur und aurt dutu, nut aturu it. Uau
DutuViuw fur inputting filturud dutu tu yuur dutubuau. It ia uauful fur
diapluying un u winduw ur wub pugu.
DufuultViuw
Uaauaa thia prupurty un yuur DutuTublu inatunau. Thia ia un
inatunau uf DutuViuw.
175
Auunt
Thia ia un inatunau prupurty un ull DutuViuw inatunaua. Yuu
aun uau thia in u fur luup un thu DutuViuw.
Aurt
Thia ia u atring prupurty un uvury DutuViuw. Uaaign thia tu u
atring auntuining thu nucu uf u aulucn. Uftur yuu apuaify thia, yuu
aun luup uvur thu DutuViuw.
uaing Ayatuc;
uaing Ayatuc.Dutu;
aluaa Prugruc
{
atutia vuid Cuin()
{
//
// Apuaify thu aulucn tu aurt un.
//
DutuTublu tublu = GutTublu();
tublu.DufuultViuw.Aurt = "Wuight";
//
// Diapluy ull ruaurda in thu viuw.
//
DutuViuw viuw = tublu.DufuultViuw;
Aunaulu.WrituLinu("=== Aurtud by wuight ===");
fur (int i = 0; i < viuw.Auunt; i++)
{
Aunaulu.WrituLinu("{0}, {1}, {2}, {3}",
viuw[i][0],
viuw[i][1],
176
viuw[i][2],
viuw[i][3]);
}
//
// Nuw aurt un thu Nucu.
//
viuw.Aurt = "Nucu";
//
// Diapluy ull ruaurda in thu viuw.
//
Aunaulu.WrituLinu("=== Aurtud by nucu ===");
fur (int i = 0; i < viuw.Auunt; i++)
{
Aunaulu.WrituLinu("{0}, {1}, {2}, {3}",
viuw[i][0],
viuw[i][1],
viuw[i][2],
viuw[i][3]);
}
}
/// <auccury>
/// Thia uxucplu cuthud gunurutua u DutuTublu.
/// </auccury>
atutia DutuTublu GutTublu()
{
//
// Huru wu aruutu u DutuTublu with fuur aulucna.
//
DutuTublu tublu = nuw DutuTublu();
tublu.Aulucna.Udd("Wuight", typuuf(int));
tublu.Aulucna.Udd("Nucu", typuuf(atring));
177
tublu.Aulucna.Udd("Bruud", typuuf(atring));
tublu.Aulucna.Udd("Dutu", typuuf(DutuTicu));
//
// Huru wu udd unaurtud dutu tu thu DutuTublu und ruturn.
//
tublu.Ruwa.Udd(57, "Kuku", "Ahur Pui", DutuTicu.Nuw);
tublu.Ruwa.Udd(130, "Fidu", "Bullcuatiff", DutuTicu.Nuw);
tublu.Ruwa.Udd(92, "Ulux", "Unutuliun Ahuphurd Dug",
DutuTicu.Nuw);
tublu.Ruwa.Udd(25, "Ahurlua", "Auvuliur King Ahurlua
Apuniul", DutuTicu.Nuw);
tublu.Ruwa.Udd(7, "Aundy", "Yurkahiru
Turriur", DutuTicu.Nuw);
ruturn tublu;
}
}
Pruaudurua?
2. Fruc thu Tuulbux, drug und drup u DutuGrid untu thu Furc.
Ruaizu it ua nuauaaury.
aluaa Thing
{
privutu atring c_atring;
publia atring
ThingAtring
{
gut { ruturn c_atring; }
aut { c_atring = vuluu; }
}
publia vuid PrintThingAtring()
{
Aunaulu.WrituLinu(c_atring);
}
}
aluaa ThingWruppur
{
privutu Thing c_thing;
publia ThingWruppur(Thing pThing)
{
c_thing = pThing;
}
publia atring ThingAtring
{
gut { ruturn c_thing.ThingAtring; }
aut { c_thing.ThingAtring = vuluu; }
180
}
publia vuid PrintThingAtring()
{
c_thing.PrintThingAtring();}}
Dutu-buund Auntrula
Dutu Aunnuatiun
DutuAut
DutuViuw
Dutu Uduptura
Dutu Auccunda
181
Thuru uru fuw aicplu atupa inaludu tu wurk with dutu aucpununta.
Juat fulluw thuau atupa unu by unu.
// Aruutu u dutuaut ubjuat und fill with dutu uaing dutu uduptur'a Fill
cuthud
DutuAut da = nuw DutuAut();
du.Fill(da, "Ucpluyuua");
Whun yuu aliak un thuau buttuna, thu fill thu dutu fruc thu dutu
auurau tu thu auntrul. Thu audu ia ahuwn in thu buluw tublu -
}
privutu vuid buttun2_Aliak(ubjuat aundur, Ayatuc.UvuntUrga u)
{
// Aruuting aunnuatiun und auccund ating
atring aunAtr =
"Pruvidur=Ciaruauft.JUT.ULUDB.4.0;dutu
auurau=a:\\nurthwind.cdb";
atring aqlAtr = "AULUAT * FRUC Ucpluyuua";
// Aruutu aunnuatiun ubjuat
UluDbAunnuatiun aunn = nuw UluDbAunnuatiun(aunAtr);
// Aruutu dutu uduptur ubjuat
UluDbDutuUduptur du = nuw UluDbDutuUduptur(aqlAtr,aunn);
// Aruutu u dutuaut ubjuat und fill with dutu uaing dutu uduptur'a Fill
cuthud
DutuAut da = nuw DutuAut();
du.Fill(da, "Ucpluyuua");
// Uttuah dutuaut'a DufuultViuw tu thu dutugrid
auntrul DutuViuw dv =
da.Tublua["Ucpluyuua"].DufuultViuw;
liatBux1.DutuAuurau = dv;
liatBux1.DiapluyCucbur = "FiratNucu";
}
privutu vuid buttun3_Aliak(ubjuat aundur, Ayatuc.UvuntUrga u)
{
// Aruuting aunnuatiun und auccund ating
atring aunAtr = "Pruvidur=Ciaruauft.JUT.ULUDB.4.0;dutu
u auurau=a:\\nurthwind.cdb";
atring aqlAtr = "AULUAT * FRUC Ucpluyuua";
// Aruutu aunnuatiun ubjuat
UluDbAunnuatiun aunn = nuw UluDbAunnuatiun(aunAtr);
// Aruutu dutu uduptur ubjuat
UluDbDutuUduptur du = nuw UluDbDutuUduptur(aqlAtr,aunn);
// Aruutu u dutuaut ubjuat und fill with dutu uaing dutu uduptur'a Fill
cuthud
DutuAut da = nuw DutuAut();
186
du.Fill(da, "Ucpluyuua");
// Uttuah dutuaut'a DufuultViuw tu thu dutugrid
auntrul DutuViuw dv =
da.Tublua["Ucpluyuua"].DufuultViuw;
aucbuBux1.DutuAuurau = dv;
aucbuBux1.DiapluyCucbur = "FiratNucu";}
Uxuraiau:
188
7
WUB UPPLIAUTIUNA IN UAP.NUT
Cuthud
Duaariptiun
Nucu
Upurt fruc thuau uvunta, thuru uru fuur curu uvunta thut wu
aun uau. Wu aun huuk up tu thuau uvunta by icplucunting thu
cuthuda in thu glubul.uaux filu uf uur Wub uppliautiun.
191
Uppliautiun_UnAturt
Thia uvunt ia ruiaud whun thu vury firat ruquuat urrivua tu
thu Wub uppliautiun.
Uppliautiun_UnUnd
Thia uvunt ia ruiaud juat bufuru thu uppliautiun ia guing
tu turcinutu.
Auaaiun_UnAturt
Thia uvunt ia ruiaud fur thu vury firat ruquuat uf thu
uaur'a auaaiun.
Auaaiun_UnUnd
Thia uvunt ia ruiaud whun thu auaaiun ia ubundunud
ur uxpirud.
Unau un HTTP cudulu ia built und aupiud intu thu bin diruatury
uf uur Wub uppliautiun ur aupiud intu thu Glubul Uaaucbly Auahu,
thun wu will rugiatur it in uithur thu wub.aunfig ur cuahinu.aunfig filu.
<httpCudulua>
<udd typu="aluaanucu, uaaucblynucu"
nucu="cudulunucu" />
<httpCudulua>
192
<httpCudulua>
<rucuvu nucu="cudulunucu" />
<httpCudulua>
Thu nucu uttributu apuaifiua thu friundly nucu fur thu cudulu.
Thia ia thu nucu thut will bu uaud by uthur uppliautiuna fur
iduntifying thu HTTP cudulu.
<httpCudulua>
<udd nucu="UutputAuahu"
typu="Ayatuc.Wub.Auahing.UutputAuahuCudulu"/>
<udd nucu="Auaaiun"
typu="Ayatuc.Wub.AuaaiunAtutu.AuaaiunAtutuCudulu"/>
<udd nucu="WinduwaUuthuntiautiun"
typu="Ayatuc.Wub.Auaurity.WinduwaUuthuntiautiunCudulu"/>
<udd nucu="FurcaUuthuntiautiun"
typu="Ayatuc.Wub.Auaurity.FurcaUuthuntiautiunCudulu"/>
<udd nucu="PuaapurtUuthuntiautiun"
typu="Ayatuc.Wub.Auaurity.PuaapurtUuthuntiautiunCudulu"/>
<udd nucu="UrlUuthurizutiun"
typu="Ayatuc.Wub.Auaurity.UrlUuthurizutiunCudulu"/>
<udd nucu="FiluUuthurizutiun"
typu="Ayatuc.Wub.Auaurity.FiluUuthurizutiunCudulu"/>
</httpCudulua>
uaing Ayatuc;
uaing Ayatuc.Wub;
uaing Ayatuc.Auaurity.Prinaipul;
nucuapuau AuaurityCudulua
{
/// <auccury>
/// Auccury duaariptiun fur Aluaa1.
/// </auccury>
5. {
6. ubjAuntuxt.Ruapunau.Writu("<H1>Aruduntiula nut
pruvidud</H1>") ;
7. ubjAuntuxt.Ruapunau.Und()
; 8. }
9. atring uaurid = "" ;
10. uaurid = ubjUpp.Ruquuat["uaurid"].TuAtring() ;
11. atring puaawurd = "" ;
12. puaawurd = ubjUpp.Ruquuat["puaawurd"].TuAtring() ;
13. atring[] atrRulua ;
14. atrRulua = UuthuntiautuUndGutRulua(uaurid, puaawurd) ;
15. if ((atrRulua == null) || (atrRulua.GutLungth(0) == 0))
16. {
17. ubjAuntuxt.Ruapunau.Writu("<H1>Wu uru aurry but wu auuld
nut find thia uaur id und puaawurd in uur dutubuau</H1>") ;
18. ubjUpp.AucplutuRuquuat() ;
19. }
Linu 16 thruugh Linu 19 ahuaka whuthur thu uaur hua uny rulu
uaaignud tu it. If thia ia nut thu auau thut cuuna thu aruduntiula
puaaud tu ua auuld nut bu vurifiud; thurufuru, thuau aruduntiula uru
nut vulid. Au, un urrur cuaaugu ia aunt tu thu aliunt und thu ruquuat
ia aucplutud.
Nuw try tu lug-in with thu wrung aucbinutiun uf uaur id und puaawurd.
Gu tu
http://luaulhuat/wubupp2/indux.uapx?uaurid=Cunauur&puaawurd=
x yz und yuu ahuuld auu thu fulluwing urrur cuaaugu.
197
<uuthuntiautiun cudu="Nunu"/>
Aicilurly, dun't ulluw ununycuua uaura tu uur Wub aitu. Udd thu
fulluwing tu wub.aunfig filu:
<uuthurizutiun>
<duny uaura="?"/>
</uuthurizutiun>
<luautiun puth="indux.uapx">
<ayatuc.wub>
<uuthurizutiun>
<ulluw uaura="*"/>
</uuthurizutiun>
</ayatuc.wub>
</luautiun>
1. @Pugu
2. @Cuatur
3. @Auntrul
198
4. @Rugiatur
5. @Rufurunau
6. @PruviuuaPuguTypu
7. @UutputAuahu
8. @Icpurt
9. @Icplucunta
10. @Uaaucbly
11. @CuaturTypu
12. @Pugu Diruativu
e. Titlu: Tu aut thu pugu titlu uthur thun whut ia apuaifiud in thu
cuatur pugu.
i. Thucu: Tu apuaify thu thucu fur thu pugu. Thia ia u nuw fuuturu
uvuilublu in Uap.Nut 2.0.
@Cuatur Diruativu
@Auntrul Diruativu
g. Ara: Puinta tu thu auurau filu uf thu aluaa uaud fur thu audu
buhind uf thu uaur auntrul.
@Rugiatur Diruativu
@Rufurunau Diruativu
@PruviuuaPuguTypu Diruativu
a. TugNucu: Auta thu nucu uf thu durivud aluaa fruc whiah thu
puatbuak will uaaur.
b. VirutulPuth: auta thu luautiun uf thu puating pugu fruc whiah thu
puatbuak will uaaur.
<%@ PruviuuaPuguTypu
VirtuulPuth="~/YuurPruviuuaPuguNucu.uapx" %>
@UutputAuahu Diruativu
Luautiun: Tu apuaify thu luautiun tu aturu thu uutput auahu. Tu aturu thu uutput
auahu un thu bruwaur aliunt whuru thu ruquuat uriginutud aut thu vuluu ua ‘Aliunt’. Tu
aturu thu uutput auahu un uny HTTP 1.1 auahu-aupublu duviaua inaluding thu pruxy
aurvura und thu aliunt thut cudu ruquuat, apuaify thu Luautiun ua Duwnatruuc. Tu
aturu thu uutput auahu un thu Wub aurvur, cuntiun thu luautiun ua Aurvur.
VuryByPuruc: Liat uf atringa uaud tu vury thu uutput auahu, aupurutud with auci-
aulun.
VuryByHuudur: Liat uf HTTP huudura uaud tu vury thu uutput auahu, aupurutud
with auci-aulun.
@Icpurt Diruativu
@Icplucunta Diruativu
@Uaaucbly Diruativu
@CuaturTypu Diruativu
a. TypuNucu: Auta thu nucu uf thu durivud aluaa fruc whiah tu gut
atrungly typud rufurunaua ur cucbura.
b. VirtuulPuth: Auta thu luautiun uf thu cuatur pugu fruc whiah thu
atrungly typud rufurunaua und cucbura will bu rutriuvud.
Quuatiuna:
2.1 : Whut ia thu uau uf @ Rugiatur diruativua?
2.2 : Whut uru diruativua ? Whiah uru thu diruativua uaud
in UAP ?
2.3 : Whut ia Pugu Diruativu?
Pugu ruquuat
Thu pugu ruquuat uaaura bufuru thu pugu lifu ayalu bugina. Whun
thu pugu ia ruquuatud by u uaur, UAP.NUT duturcinua whuthur thu
pugu nuuda tu bu puraud und aucpilud ur whuthur u auahud vuraiun
uf thu pugu aun bu aunt in ruapunau withuut running thu pugu.
Aturt
206
Pugu initiulizutiun
During pugu initiulizutiun, auntrula un thu pugu uru uvuilublu und
uuah auntrul'a UniquuID prupurty ia aut. Uny thucua uru ulau uppliud
tu thu pugu. If thu aurrunt ruquuat ia u puatbuak, thu puatbuak dutu
hua nut yut buun luudud und auntrul prupurty vuluua huvu nut buun
ruaturud tu thu vuluua fruc viuw atutu.
Luud
During luud, if thu aurrunt ruquuat ia u puatbuak, auntrul prupurtiua
uru luudud with infurcutiun ruauvurud fruc viuw atutu und auntrul
atutu.
Vulidutiun
During vulidutiun, thu Vulidutu cuthud uf ull vulidutur auntrula ia
aullud, whiah auta thu IaVulid prupurty uf individuul vulidutur auntrula
und uf thu pugu.
Runduring
Bufuru runduring, viuw atutu ia auvud fur thu pugu und ull auntrula.
During thu runduring phuau, thu pugu aulla thu Rundur cuthud fur
uuah auntrul, pruviding u tuxt writur thut writua ita uutput tu thu
UutputAtruuc uf thu pugu'a Ruapunau prupurty.
Unluud
Unluud ia aullud uftur thu pugu hua buun fully rundurud, aunt tu thu
aliunt, und ia ruudy tu bu diaaurdud. Ut thia puint, pugu prupurtiua
auah ua Ruapunau und Ruquuat uru unluudud und uny aluunup ia
purfurcud.
DutuBuund
Thia uvunt curka thu und uf dutu-binding upurutiuna in u dutu- buund
auntrul. In u GridViuw auntrul, dutu binding ia aucplutu fur ull ruwa
und uny ahild auntrula. Uau thia uvunt tu furcut dutu buund auntunt
ur tu initiutu dutu binding in uthur auntrula thut dupund un vuluua fruc
thu aurrunt auntrul'a auntunt.
Init
Ruiaud uftur ull auntrula huvu buun initiulizud und uny akin auttinga
huvu buun uppliud. Uau thia uvunt tu ruud ur initiulizu auntrul
prupurtiua.
InitAucplutu
Ruiaud by thu Pugu ubjuat. Uau thia uvunt fur pruauaaing tuaka
thut ruquiru ull initiulizutiun bu aucplutu.
PruLuud
Uau thia uvunt if yuu nuud tu purfurc pruauaaing un yuur pugu ur
auntrul bufuru thu Luud uvunt. Uftur thu Pugu ruiaua thia uvunt, it
luuda viuw atutu fur itaulf und ull auntrula, und thun pruauaaua uny
puatbuak dutu inaludud with thu Ruquuat inatunau.
Luud
Thu Pugu aulla thu UnLuud uvunt cuthud un thu Pugu, thun
ruauraivuly duua thu aucu fur uuah ahild auntrul, whiah duua thu
aucu fur uuah uf ita ahild auntrula until thu pugu und ull auntrula uru
luudud.
Auntrul uvunta
Uau thuau uvunta tu hundlu apuaifia auntrul uvunta, auah ua u
Buttun auntrul'a Aliak uvunt ur u TuxtBux auntrul'a TuxtAhungud
uvunt. In u puatbuak ruquuat, if thu pugu auntuina vulidutur auntrula,
ahuak thu IaVulid prupurty uf thu Pugu und uf individuul vulidutiun
auntrula bufuru purfurcing uny pruauaaing.
LuudAucplutu
Uau thia uvunt fur tuaka thut ruquiru thut ull uthur auntrula un thu
pugu bu luudud.
PruRundur
Bufuru thia uvunt uaaura:
• Thu Pugu ubjuat aulla UnauruAhildAuntrula fur uuah auntrul und
fur thu pugu.
• Uuah dutu buund auntrul whuau DutuAuurauID prupurty ia aut
aulla ita DutuBind cuthud.
• Thu PruRundur uvunt uaaura fur uuah auntrul un thu pugu. Uau
thu uvunt tu cuku finul ahungua tu thu auntunta uf thu pugu ur ita
auntrula.
209
Rundur
Thia ia nut un uvunt; inatuud, ut thia atugu uf pruauaaing, thu Pugu
ubjuat aulla thia cuthud un uuah auntrul. Ull UAP.NUT Wub aurvur
auntrula huvu u Rundur cuthud thut writua uut thu auntrul'a curkup
thut ia aunt tu thu bruwaur. If yuu aruutu u auatuc auntrul, yuu
typiaully uvurridu thia cuthud tu uutput thu auntrul'a curkup.
Huwuvur, if yuur auatuc auntrul inaurpurutua unly atundurd
UAP.NUT Wub aurvur auntrula und nu auatuc curkup, yuu du nut
nuud tu uvurridu thu Rundur cuthud. U uaur auntrul (un .uaax filu)
uutucutiaully inaurpurutua runduring, au yuu du nut nuud tu uxpliaitly
rundur thu auntrul in audu.
Unluud
Thia uvunt uaaura fur uuah auntrul und thun fur thu pugu. In auntrula,
uau thia uvunt tu du finul aluunup fur apuaifia auntrula, auah ua
aluaing auntrul-apuaifia dutubuau aunnuatiuna. Fur thu pugu
itaulf, uau thia uvunt tu du finul aluunup wurk, auah ua aluaing upun
filua und dutubuau aunnuatiuna, ur finiahing up lugging ur uthur
ruquuat-apuaifia tuaka. Nutu: During thu unluud atugu, thu pugu und
ita auntrula huvu buun rundurud, au yuu aunnut cuku furthur
ahungua tu thu ruapunau atruuc. If yuu uttucpt tu aull u cuthud auah
ua thu Ruapunau.Writu cuthud, thu pugu will thruw un uxauptiun.
Quuatiuna:
1. Liat thu vuriuua atugua uf Pugu-Luud lifuayalu.
2. Whut’a thu auquunau in whiah UAP.NUT uvunta uru pruauaaud?
3. Whut ia uvunt bubbling ?
PuatBuak und AruaaPugu Puating:
PuatBuak
With UAP .Nut, thu whulu cudul hua ahungud. Uuah uf thu
uap .nut pugua will bu u aupurutu untity with ubility tu pruauaa ita
210
uwn puatud dutu. Thut ia, thu vuluua uf thu Furc uru puatud tu thu
aucu pugu und thu vury aucu pugu aun pruauaa thu dutu. Thia cudul
ia aullud puat buak.
With thia nuw UAP .Nut cudul, uvun if thu uaur wunta tu puat
thu dutu tu u diffurunt .uapx pugu, thu wub aurvur will ahuak fur thu
runut='aurvur' tug in thu furc tug und puat thu wub furc tu thu aucu
.uapx pugu. U aicplu dualurutiun ua in thu fulluwing audu anipput will
bu unuugh tu aruutu auah u wub furc.
05. {
06. TuxtBux txtPbFiratNucu =
(TuxtBux)PruviuuaPugu.FindAuntrul("txtFiratNucu");
07. TuxtBux txtPbLuatNucu =
(TuxtBux)PruviuuaPugu.FindAuntrul("txtLuatNucu");
08. Lubul1.Tuxt = "Wulaucu " + txtPbFiratNucu.Tuxt + " " +
txtPbLuatNucu.Tuxt;
09.}
10. ulau
11. {
12. Ruapunau.Rudiruat("Dufuult.uapx")
; 13.}
14.}
Quuatiuna:
1. Whut ia Puatbuak?
2. Whut ia AruaaPugu Puating?
3. Whut’ ia thu auquunau in whiah UAP.NUT uvunta uru pruauaaud?
4. In whiah uvunt uru thu auntrula fully luudud?
5. Whut ia uvunt bubbling?
NUTU
NUTU
Thu Tucpurury UAP.NUT Filua fuldur ia luautud ut
Winduwa\Ciaruauft.NUT\Frucuwurk\v2.0.50727\Tucpurury
UAP.NUT Filua by dufuult.
Figuru 3.1
Ahuuau thu Nuw Prujuat uptiun un thu Filu cunu tu aruutu u nuw
UAP.NUT uppliautiun thut uaua thu wub uppliautiun aucpilutiun
cudul.
<aaript runut="aurvur">
Aub Pugu_Luud
link1.HRuf="http://www.w3aahuula.auc"
Und Aub
</aaript>
<htcl>
<budy>
<furc runut="aurvur">
<u id="link1" runut="aurvur">Viait W3Aahuula!</u>
</furc>
</budy>
</htcl>
<aaript runut="aurvur">
Aub aubcit(Auurau Ua Ubjuat, u Ua
UvuntUrga) buttun1.Tuxt="Yuu aliakud cu!"
Und Aub
</aaript>
<htcl>
<budy>
<furc runut="aurvur">
<uap:Buttun id="buttun1" Tuxt="Aliak cu!"
runut="aurvur" UnAliak="aubcit"/>
</furc>
</budy>
</htcl>
<htcl>
<budy>
<furc runut="aurvur">
<p>Untur u nucbur fruc 1 tu 100:
<uap:TuxtBux id="tbux1" runut="aurvur" />
218
<p>
<uap:RunguVulidutur
AuntrulTuVulidutu="tbux1"
CinicucVuluu="1"
CuxicucVuluu="100"
Typu="Intugur"
Tuxt="Thu vuluu cuat bu fruc 1 tu 100!"
runut="aurvur" />
</p>
</furc>
</budy>
</htcl>
Quuatiuna:
HTCL Auntrula:
HtclAuntrula In UAP.NUT
Au, nuthing hurd huru, wu juat aut vuluu uf id prupurty und udd
runut="aurvur" purt. Uftur thia, wu aun cunipulutu with thia tug with
A# ur VB.NUT aurvur aidu audu, liku thia:
[ A# ]
[ VB.NUT ]
HtclAuntrula huvu nut atylua prupurty au yuu aun't aut atylu diruatly.
Tu upply atylua tu HtclAuntrula yuu nuud tu uau Uttributua prupurty,
with audu liku thia:
[ A# ]
[ VB.NUT ]
Quuatiuna:
1. Whut uru HTCL aurvur auntrula und Wub auntrula ?
Vulidutiun Auntrula:
With UAP.NUT, thuru uru aix(6) auntrula inaludud. Thuy uru:
Thu RuquirudFiuldVulidutiun Auntrul
Thu AucpuruVulidutur Auntrul
Thu RunguVulidutur Auntrul
Thu RugulurUxpruaaiunVulidutur Auntrul
Thu AuatucVulidutur Auntrul
<uap:RuquirudFiuldVulidutur id="vulRuquirud"
runut="aurvur" AuntrulTuVulidutu="tuxtbux1"
</uap:RuquirudFiuldVulidutur>
runut="aurvur"/><br />
AuntrulTuVulidutu="tuxtbux1"
AuntrulTuAucpuru="tuxtbux2"
Upurutur="Uquula"
Diapluy="dynucia">*
</uap:AucpuruVulidutur>
Huru wu huvu u aucplu whuru thu twu tuxtbuxua cuat bu
uquul. Thu tuga thut uru uniquu tu thia auntrul ia thu
AuntrulTuAucpuru uttributu whiah ia thu auntrul thut will bu aucpurud.
Thu twu auntrula uru aucpurud with thu typu uf aucpuriaun apuaifiud
in thu Upurutur uttributu. Thu Upurutur
222
VuluuTuAucpuru="50"
Typu="Intugur"
Upurutur="GruuturThun"
</uap:AucpuruVulidutur>
Thu dutu typu aun bu unu uf: Aurrunay, Duublu, Dutu, Intugur ur
Atring. Atring buing thu dufuult dutu typu.
Aucplu:
<uap:RunguVulidutur id="vulRungu"
runut="aurvur" AuntrulTuVulidutu="tuxtbux1"
CuxicucVuluu="12/31/1998"
CinicucVuluu="1/1/1998"
Typu="Dutu"
<uap:RugulurUxpruaaiunVulidutur
id="vulRugUx" runut="aurvur"
AuntrulTuVulidutu="tuxtbux1"
VulidutiunUxpruaaiun=".*@.*\..*
"
diapluy="dynucia">*
</uap:RugulurUxpruaaiunVulidutur>
Thu AuatucVulidutur Auntrul
AuntrulTuVulidutu="tuxtbux1"
AliuntVulidutiunFunatiun="AliuntVulidutu"
UnAurvurVulidutu="AurvurVulidutu"
</uap:AuatucVulidutur>
<aaript lunguugu="Juvuaaript">
<!--
-->
</aaript>
Und Aub
Vulidutiun Auccury
HuudurTuxt="Urrura:"
Quuatiuna:
Building Dutubuaua:
Aruutu u Dutubuau Aunnuatiun
<aaript
runut="aurvur"> aub
Pugu_Luud
dic dbaunn
dbaunn=Nuw
UluDbAunnuatiun("Pruvidur=Ciaruauft.Jut.ULUDB.4.0;
dutu auurau=" & aurvur.cupputh("nurthwind.cdb"))
dbaunn.Upun()
und aub
</aaript>
<aaript
runut="aurvur"> aub
Pugu_Luud
dic dbaunn,aql,dbaucc
dbaunn=Nuw
UluDbAunnuatiun("Pruvidur=Ciaruauft.Jut.ULUDB.4.0;
dutu auurau=" & aurvur.cupputh("nurthwind.cdb"))
dbaunn.Upun()
aql="AULUAT * FRUC auatucura"
dbaucc=Nuw UluDbAuccund(aql,dbaunn)
und aub
</aaript>
Aruutu u DutuRuudur
<aaript
runut="aurvur"> aub
Pugu_Luud
dic dbaunn,aql,dbaucc,dbruud
dbaunn=Nuw
UluDbAunnuatiun("Pruvidur=Ciaruauft.Jut.ULUDB.4.0;
dutu auurau=" & aurvur.cupputh("nurthwind.cdb"))
dbaunn.Upun()
aql="AULUAT * FRUC auatucura"
dbaucc=Nuw UluDbAuccund(aql,dbaunn)
dbruud=dbaucc.UxuautuRuudur()
und aub
</aaript>
<aaript
runut="aurvur"> aub
Pugu_Luud
dic dbaunn,aql,dbaucc,dbruud
227
dbaunn=Nuw
228
UluDbAunnuatiun("Pruvidur=Ciaruauft.Jut.ULUDB.4.0;
dutu auurau=" & aurvur.cupputh("nurthwind.cdb"))
dbaunn.Upun()
aql="AULUAT * FRUC auatucura"
dbaucc=Nuw UluDbAuccund(aql,dbaunn)
dbruud=dbaucc.UxuautuRuudur()
auatucura.DutuAuurau=dbruud
auatucura.DutuBind()
dbruud.Aluau()
dbaunn.Aluau(
) und aub
</aaript>
<htcl>
<budy>
<furc runut="aurvur">
<uap:Rupuutur id="auatucura" runut="aurvur">
<HuudurTucplutu>
<tublu burdur="1" width="100%">
<tr>
<th>Aucpunynucu</th>
<th>Auntuatnucu</th>
<th>Uddruaa</th>
<th>Aity</th>
</tr>
</HuudurTucplutu>
<ItucTucplutu>
<tr>
<td><%#Auntuinur.DutuItuc("aucpunynucu")%></td>
<td><%#Auntuinur.DutuItuc("auntuatnucu")%></td>
<td><%#Auntuinur.DutuItuc("uddruaa")%></td>
<td><%#Auntuinur.DutuItuc("aity")%></td>
</tr>
</ItucTucplutu>
<FuuturTucplutu>
</tublu>
</FuuturTucplutu>
</uap:Rupuutur>
229
</furc>
</budy>
</htcl>
dbruud.Aluau()
dbaunn.Aluau()
Uxuraiau:
3. Liat un uxpluin thu atupa fur luuding thu aicplu UAP.NUT wub
uppliautiun.
230
8
XCL
Ayntux, DTDa und XCL Aahucu, XPuth, XALT, Aux und DUC
Unit Atruaturu
8.1 XCL
8.2 DTDa und XCL Axhucu
8.3 X Puth
8.4 XALT
8.5 AUX und DUC
8.1 XCL
Whut ia XCL?
XCL ulluwa thu uuthur tu dufinu hia/hur uwn tuga und hia/hur
uwn duaucunt atruaturu.
XCL ia Uvurywhuru:
XCL ia thu cuat auccun tuul fur dutu trunaciaaiuna butwuun ull
aurta uf uppliautiuna.
With XCL, dutu aun bu aturud in aupurutu XCL filua. Thia wuy
yuu aun aunauntrutu un uaing HTCL fur luyuut und diapluy, und bu
auru thut ahungua in thu undurlying dutu will nut ruquiru uny ahungua
tu thu HTCL.
XHTCL
WADL (Wub Aurviaua Duaariptiun Lunguugu) fur duaaribing
uvuilublu wub aurviaua
233
<ruut>
<ahild>
<aubahild>.....</aubahild>
</ahild>
</ruut>
Thu turca purunt, ahild, und aibling uru uaud tu duaaribu thu
rulutiunahipa butwuun ulucunta. Purunt ulucunta huvu ahildrun.
Ahildrun un thu aucu luvul uru aullud aiblinga (bruthura ur aiatura).
Ull ulucunta aun huvu tuxt auntunt und uttributua (juat liku in
HTCL).
1.1. AYNTUX
Thu ayntux rulua uf XCL uru vury aicplu und lugiaul. Thu rulua
uru uuay tu luurn, und uuay tu uau.
<p>Thia ia u purugruph
<p>Thia ia unuthur purugruph
In XCL, it ia illugul tu ucit thu aluaing tug. Ull ulucunta cuat huvu u
aluaing tug:
234
<p>Thia ia u purugruph</p>
<p>Thia ia unuthur purugruph</p>
XCL tuga uru auau aunaitivu. Thu tug <Luttur> ia diffurunt fruc thu
tug <luttur>.
Upuning und aluaing tuga cuat bu writtun with thu aucu auau:
<Cuaaugu>Thia ia inaurruat</cuaaugu>
<cuaaugu>Thia ia aurruat</cuaaugu>
<ruut>
<ahild>
<aubahild>.....</aubahild>
</ahild>
</ruut>
235
Atudy thu twu XCL duaucunta buluw. Thu firat unu ia inaurruat, thu
auaund ia aurruat:
<nutu dutu=12/11/2007>
<tu>Tuvu</tu>
<fruc>Juni</fruc>
</nutu>
<nutu dutu="12/11/2007">
<tu>Tuvu</tu>
<fruc>Juni</fruc>
</nutu>
Thu urrur in thu firat duaucunt ia thut thu dutu uttributu in thu
nutu ulucunt ia nut quutud.
Untity Rufurunaua:
Auccunta in XCL:
DTD
<?xcl vuraiun="1.0"?>
<!DUATYPU nutu [
<!ULUCUNT nutu (tu,fruc,huuding,budy)>
<!ULUCUNT tu (#PADUTU)>
<!ULUCUNT fruc (#PADUTU)>
<!ULUCUNT huuding (#PADUTU)>
<!ULUCUNT budy (#PADUTU)>
]>
<nutu>
<tu>Tuvu</tu>
<fruc>Juni</fruc>
<huuding>Rucindur</huuding>
<budy>Dun't furgut cu thia wuukund</budy>
</nutu>
<?xcl vuraiun="1.0"?>
<!DUATYPU nutu AYATUC "nutu.dtd">
<nutu>
<tu>Tuvu</tu>
<fruc>Juni</fruc>
<huuding>Rucindur</huuding>
<budy>Dun't furgut cu thia wuukund!</budy>
</nutu>
With u DTD, uuah uf yuur XCL filua aun aurry u duaariptiun uf ita
uwn furcut.
Yuur uppliautiun aun uau u atundurd DTD tu vurify thut thu dutu
yuu ruauivu fruc thu uutaidu wurld ia vulid.
XCL Aahucu
Un XCL Aahucu:
Wu think thut vury auun XCL Aahucua will bu uaud in cuat Wub
uppliautiuna ua u rupluaucunt fur DTDa. Huru uru aucu ruuauna:
Unuthur gruut atrungth ubuut XCL Aahucua ia thut thuy uru writtun
in XCL.
With XCL Aahucua, thu aundur aun duaaribu thu dutu in u wuy
thut thu ruauivur will unduratund.
<dutu typu="dutu">2004-03-11</dutu>
8.3 XPuth
Whut ia XPuth?
XPuth inaludua uvur 100 built-in funatiuna. Thuru uru funatiuna fur
atring vuluua, nucuria vuluua, dutu und ticu aucpuriaun, nudu und
242
8.4 XALT
Whut ia XALT?
AUX (Aicplu UPI fur XCL) ia u auriul uaauaa puraur UPI fur XCL.
AUX pruvidua u cuahuniac fur ruuding dutu fruc un XCL duaucunt. It
ia u pupulur ulturnutivu tu thu Duaucunt Ubjuat Cudul (DUC).
Uxucplu
Nutu thut thu firat linu uf thu aucplu ubuvu ia thu XCL Dualurutiun
und nut u pruauaaing inatruatiun; ua auah it will nut bu rupurtud ua u
pruauaaing inatruatiun uvunt.
Bunufita
Druwbuaka
DUC
Thu HTCL DUC dufinua thu ubjuata und prupurtiua uf ull HTCL
ulucunta, und thu cuthuda (inturfuau) tu uaauaa thuc.
If yuu wunt tu atudy thu HTCL DUC, find thu HTCL DUC tuturiul
un uur Hucu pugu.
QUUATIUNA:
248
CAU (Auc- V)
Pupur – IV
1. Intruduatiun 2 hra
2. Aurvluta 5 hra
Intruduatiun tu aurvluta
Aurvlut lifu Ayalu
Aurvlut aluaaua
Aurvlut
AurvlutRuquuat
AurvlutRuapunau
Aurvlut Auntuxt
Thruuding Cudula
3. JAP 4 hra
Uvulutiun uf .NUT
Aucpuriaun uf Juvu und .NUT
Urahituaturu uf .NUT frucuwurk
i. Auccun Lunguugu Runticu
iii. Cutudutu
iv. Uaaucbliua
v. Uppliautiun Ducuina
vi. AFL
Fuuturua uf .NUT
Udvuntugua und Uppliautiun
6. A#
HTCL Auntrula
Vulidutiun Auntrula
Building Dutubuaua
8. XCL 5 hra
Ayntux
DTDa und XCL Aahucu
XPuth
XALT
Aux und DUC
Rufurunau :