.net 2008
Transcription
.net 2008
2 3 4 5 ... ﺗﻘﺪﻳﻢ . א:אذ א، ! "א و$%&'() *+, 'ل א. אن א01א A$ 9 :ق א<زא1 > אد2343 @( و77) 2343 53 .NET Framework لB $"C 5D E$ ! א،FD G% אو وאHI אJ אKL H'1 M 23 א א+! NOPQ و،:ND E$R S 0QHT3 U :FV : W وאX אY!Z[אH 53'Sو 'لX אY4F 0F 4 אK^> W وאvb4arab 0.'\ 'ل אولJ\ א:] ._א Pא אWS a وbI ،:ND E$R U\ אP אHI אU :.ل دB $" אX' אU ^ אc`Q 3 Qو،:%d93و234\א:%d33efQ'g!،hא$N\אi^و3'\אH`O9א53Kjkدא$א 'g!(Source CodesQH$V\א:אO,$V.)אlS'א%5D3א،א(مn3oوoPאKp5Qא53א$% tوאReal World Cases77Lאh9Lא53 ^Pא1qrgsQt^א39אHIאUع$Qو5NOQ .a7!iPOאvT^3אWOPQ9و، % אمא%D234Fg( אنb'VIو..zFbD.U..z'دא1.${אنGVא53":OQ1אPLאA$'لא7!،XP'صאVx qKM!א${אنGVא53":'لא7אن5P>ND's'}g1وRF!"و, I1.NS5PQ_ $5F!"!, IqCNS'نPQ_אنb'VIو..hqא53IאאWSK&U(.NET~g%'3) ،Java)hN75DمQ9אlWSUQ$Lאbא،gjوgk7377hq4אhq3 אWS و، $ אgNF! g, 4 אhq 'نP د אنP و،(...LINQ ،WPF ،DirectX ،COM،.NET G D'F nD $FD א−:3$73 nD zN– XPא אWS GP! ،: 3H 3 Rb nD K دI XPא v,م$7QKa7!אWS@،.NETN7'لX535PF(א...،VB،C#)OhqE$R !q53^]QH$V\אhאOTא $Q$ دونVisual Studio 2008 XP'אن אN GP א53 (א$% W)אHI9 ن א1N\א אWS 53و NRb(وאY4\אT35)$'$7!،C#2343אوBasic2343:א1V3א'م$$%'Q !،qא .".NET43"لjDאFNB 6 K^3.O30s'א3'א%WI]Q53و،.NET7N9א0sאزא\'אXPאאWS1qQ GP אK F .GQ و و،Windows Forms ذج،Database Programming h א$D'א. .NET KFאHא53^אHא$b9א03hg&t)وאi$Q$אhN7אKS`Q_:א3$ND^א K^et وאWPFN7و،Data Entitieshא03م$7\אK3:%'\ אLINQN7K^3(Framework !' t وאWCF N7 و،Portable User Interfaces K7N . אم$+9 אhg% وא4 دم7 אKא 01Qאאن$%HدNא530s'א3lWSو.Distributed ApplicationsDא\'زh71%א^א9' .$وאXUg*د+, XPאU'Q5'عو%53cqQ9و5FQ9W)אQ$7אאWSizא. U]1IPH'نאP$.، אIC .NET_DKI$ROVאG7C$א5وא3YF^א.و53:sC3OPQW،(:Op3و .gא'א0وC53 א−− al-asiri.COM ﻣﻮﺟﺰ اﻟﻜﺘﺎب ﻣﻘﺪﻣﺔ اﻟﻜﺘﺎب – ﻣﻘﺪﻣﺔ اﻹﺻﺪار اﻟﺜﺎﻧﻲ ﻋﻦ Visual Studio 2010 ﻧﺒﺬة ﻋﻦ اﻟﻤﺆﻟﻒ ﺷﻜﺮ وﻋﺮﻓﺎن ﻫﺬا اﻟﻜﺘﺎب ﻣﺤﺘﻮﻳﺎت اﻟﻜﺘﺎب اﻟﺒﺎب : 02ﺗﺤﻤﻴﻞ ﻧﺴﺨﺘﻚ اﻷوﻟﻰ ﻣﻦ ﻓﻴﺠﻮال ﺳﺘﻮدﻳﻮ 2008 اﻟﺒﺎب : 03اﻟﺠﺪﻳﺪ ﻣﻊ.net 2008 اﻟﺒﺎب : 04ﻣﻔﺎﻫﻴﻢ ﺑﻴﺌﺔ .netاﻟﺮﺋﻴﺴﻴﺔ اﻟﺒﺎب : 05اﻟﻮاﺟﻬﺔ اﻷﺳﺎﺳﻴﺔ ﻟـVisual Studio 2008 اﻟﺒﺎب : 06ﻣﻜﻮﻧﺎت اﻟﻠﻐﺔ اﻟﺮﺋﻴﺴﻴﺔ ﻓﻲ .netاﻟﺠﺰء اﻷول اﻟﺒﺎب : 07ﻣﻜﻮﻧﺎت اﻟﻠﻐﺔ اﻟﺮﺋﻴﺴﻴﺔ ﻓﻲ .netاﻟﺠﺰء اﻟﺜﺎﻧﻲ اﻟﺒﺎب : 08ﻣﻘﺪﻣﺔ إﻟﻰ اﻟﺒﺮﻣﺠﺔ ﻛﺎﺋﻨﻴﺔ اﻟﺘﻮﺟﻪOOP اﻟﺒﺎب : Interfaces - 09اﻟﻮاﺟﻬﺎت اﻟﺒﺎب : 10اﻷﺧﻄﺎء واﻗﺘﻨﺎﺻﻬﺎ اﻟﺒﺎب : 11اﻟﺘﺠﻤﻴﻌﺎتCollections اﻟﺒﺎب : 12اﻟﺒﺮﻣﺠﺔ اﻟﻤﺘﻘﺪﻣﺔ ﻓﻲ.net 2008 اﻟﺒﺎب : 13اﻹدﺧﺎل واﻹﺧﺮاج ﺗﺤﺖSystem.IO اﻟﺒﺎب : 14ﺑﺮﻣﺠﺔ اﻟﻨﻮاﻓﺬWindows Forms اﻟﺒﺎب GDI+: 15 اﻟﺒﺎب : Windows Presentation Foundation16 اﻟﺒﺎب : 17ﻗﻮاﻋﺪ اﻟﺒﻴﺎﻧﺎت ﺑﺎﺳﺘﺨﺪامADO.net اﻟﺒﺎب LINQ: 18 اﻟﺒﺎب WWF: 19 اﻟﺒﺎب WCF: 20 اﻟﺒﺎب : 21ﻧﻘﺎط ﻣﺘﻘﺪﻣﺔ اﻟﺒﺎب : 22ﺗﻄﻮﻳﺮ اﻟﻤﻮاﻗﻊ ﺑﺎﺳﺘﺨﺪامASP.net ﺧﺎﺗﻤﺔ اﻟﻜﺘﺎب ،وﺷﻜﺮ اﻟﻤﺼﺎدر 7 9 11 12 13 14 15 29 35 45 63 73 97 129 167 183 197 211 277 305 349 361 411 477 499 499 509 509 521 539 539 602 603 8 9 ﻣﻘﺪﻣﺔ اﻟﻜﺘﺎب .YBC:Rbو:nDو$F)N،Y\وאzאf,CnDوא~ مi V~وא،א5"אא .ً gنLאK{C ًوg:%39Kg9gא !`'אلA$N3nDg,CHא$3nDhFوسאH$א530F{5DiHD'SXPאאWg!...$3C 53و، 20084FولCUא$FrgN3zg9א،i$Q$ א.net 2008hN7'لX .א'مQ$QYl${WאXP'אSN3X5FsgDi$Q$%h!sא0sو03gF{ Andrew opF Pro C# 2008 and the .NET 3.5 PlatformXizא.$hz%XPאiP! ،!'وPQ353i$Q$ אC#+N*3KPQ<אqً 3ً%3h$%و، Troelsen GC i%'3iH'V 1CDزCنC01CcC9אq0%3KFF.אDدC9C03و UFא01 MSDN53aوאHC$QFو، VB وC#:q .netلאلUjطא7Nא .i$nDلK Q3K3KV!Qg$fنCً ^3c3(N !،317Nً 3,ً VO${5}HXPאאWSU g'وg37QوiאدאlWSN'لh3'\א53H$.4CnDfא01NPو،hאدوא$] Dh71H'1FDد53^C .netNg!: I5301نf$gQXPאאWg!، KIدא .O+\אqאh'P303g3OوIא$אgNgOنCدون SNFtאSO\א1Q':F'م7FD1AIوאiZOאY$`ذ53و h Y $` אW ... XPא אWS 53 i$jO א53 4C KVR F א1 (N א אa X%'ل.CنCc3(N95Pi qVאh71^وא3א53 د$DXPאאWSUi'د%'\א'אدא .i'1xi'1Iً ^31אאWS ،ن1TوאO5F!]1I53ن3و،א5F!X'אb53:!نF!،ًא$O3XPאאWS'نPQنC]لאC .Kאzد'אkوאא 10 ﻣﻘﺪﻣﺔ اﻟﻨﺴﺨﺔ اﻟﺜﺎﻧﻴﺔ z1Iא53د$Dv b+NאlWSUF.،XPאאWk^א+NאSאنS$STtא+NאlWS אWSA'3YUFSFAICi30F`i'D$אHCو،אو+NאUi'د%'3tא .XPאUi'د%'\אz1IאnDhgNوאhאZ.9لאHא4DXPא ،Visual Studio 2010و.net framework 4.0Hو$b03و،2009NIوאCU]+NאlWSًMQC :NDQ$L!3אVאC9،i$Q$אhN7ضאQgNאU.א!אدUP!CN0.א'אUو n7Qو،Wh אqدونSFqאNbאhאK(وذ5P،K73XPجd ]אROVאUو،gDK3אOوi$Q$אhN7אnD ع0.א\'א0%نאCD .$Q$,HVIi$Q$אhN7وאh.وO\!אaوאH QאgN3W*IC،^Sאوو+Nא7NU$D530F:%'3PTאQgNאUو g^QنC'אDدCوو$D53KPًMQCPTאHC،XPK3FD'وq7Nم$.WאRs .S'دg%nD 11 2010 ﻓﻴﺠﻮال ﺳﺘﻮدﻳﻮ Visual Studio 2010Hא$bא0353אgND!'وPQ3NDCtوא.net framework 4.0+03 Y4Fk I53i h g!'وPQ33$.Microsoft Office 2010 P\א23א4א3و .Windows 7hFو،Zאh71وOffice03K3Pא،IDEאمאل$+א$bnDz'א P3א،ASP.net 4.0032010'Q`'אل'دO7!3WPF 4.053i$Q$%iHא$bو'!אPQ3م$7 53$Q\2010_DU$Q$`3$7\אlWSnD ع9אNP>،:! IوSilverlightאلh71zN :KbOא رابط http://www.vb4arab.com/vb/showthread.php?p=225389 א ع01!sאhאN3$.tوא،i$Q$א+Nא03C# 4.0!قH!אqא$bnD3C :NStو$353kKVOnD رابط http://ahmedgamal-technical.blogspot.com/2009/09/c-40.html .ًMQCKFאHא5FsF#i$Q$אqא23$!s9،vb.netلN3@אO :K3Pi$Q$طא7NאKbO:!!'وPQ353aאאאWSnDא عKM!C،QgNאU رابط http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx ﻋﻦ اﻟﻜﺎﺗﺐ 12 . أﺣﻤﺪ ﺟﻤﺎل ﺧﻠﻴﻔﺔ ﻋﺒﺪاﻟﻌﺎل A-Gamal@windowslive.com : اﻟﺒﺮﻳﺪ اﻹﻟﻜﺘﺮوﻧﻲ . 00966545663382 – 0020108011792 : اﻟﻤﺤﻮل : اﻟﺴﻴﺮة اﻟﺬاﺗﻴﺔ ﺑﺎﻟﻜﺎﻣﻞ ﺗﺠﺪﻫﺎ ﻫﻨﺎ http://www.vb4arab.com/vb/uploaded/3/01256435433.doc مشرف عام منتديات فيجوال بيسك للعرب www.vb4arab.com ﻣﺪوﻧﺎت ﺷﺨﺼﻴﺔ وﺗﻘﻨﻴﺔ www.AhmedGamal-Space.blogspot.com www.AhmedGamal-Technical.blogspot.com www.AhmedGamal-NET.blogspot.com – English ﻣﻠﺨﺼﺎت ﺳﺎﺑﻘﺔ ﺷﻜﺮ وﻋﺮﻓﺎن ﺷﻜﺮ وﻋﺮﻓﺎن 13 53 ^P'نא7RQص+,]Q'Fj.0.א'אU:Q$XPאאWSop3و،سNאPTQ953אPTQ9 5PQ_XPنאCً3دوWCذن53f$SC،NSSzCدCنCאאW،zD$وאzN^א sא\'אiF^אhz%nص+,אz9pS53iدO9وאfًאIًو9وCDאKM!9'W'نP (:%'אNj')Gb ذא ًbIًאP,م$.CאW،אنQ$QYSאtא زאد،4_אD UH3:%'U א:P (نnet. لI53J,KFDH)א 'نCنCא53'%HCאW،ً^ אF`53 4Cg!1DCFPXPאאWk:>$7c!,نCذnD .c3:.'QF!:j%HGIC9Cو،ذC5&5$ND د$%CF،XPאאWSg{U:97353ً^ אh$O' א3$F)س$NgFًMQC'لb'3PTא W*IC،אא¡لWSUXQ$7g`TnD:!T3وX!`'אلA$N3iHدאPTא ...אمPאi'Iא.و،H$$"Cوא0.'\אQ$3אא$DאذgN3 ،XPאאWS7Ng$D3nD gNא$F)س$Ng\א، 'D$"Cس$Ng\א53KPًMQCPTא XP אizא7 g. و53 z% £QO k P,C ، z1I − אل9 – وI XP א53 אو¢N! .i Iא+NאجאIK.K,\אlWS¤Hא$nD$D3وg%'و ... ﺷﻜﺮ ﺧﺎص ﺟﺪًا 7N U g$D\ a7! @ دلD نSH' $Ng\ وא، YF1 'א$ وG1س א$NgF ًא$% صI P, FV53ًאz$KPTאאWg'نP:%אI'א3.53S33ClאWאXPنא5Pو،XPאhQ') 3ً^ אkH$.CوkP,HC،f qאFVzgوא،N^وא39وאPאضوאX'CوhROVא .ngCUXPאאWSאجI$g%53l'W ،NSlذC!iאWאcI_HWDوא،XPאאWSאدوج$DUgN3h$Oא53KPًMQCمDPTא zN^ אj.$bא0Fو01S،tאHدUوC3אUgN3h$Oא530FًMQCPTא .XPאאWSمe:Dوא:7!'nDًאIًو9وC$FLذאK.و، ﻫﺬا اﻟﻜﺘﺎب 14 `3 QH{ h3 D S S وOffice، Windows K^3 XPא אWS U iH'W\ א23א4 אz א− .gRb9 .gQ')5Dول]لp3 GPنאC9،XPFאiא\دhQ')GאHIא− 53 ذنC ون$ H{ ض:3א$+ אو א:Q אو 'ز:D d 9 و، opF &'O) XP'ق א7 − .op\א gN3$وאl{אXوC 'אدC'د%و0N>9אWS5Pو،XPאKIدאgQ{א'אدGC − .وZPא$QnDH{2jHאً'א$א]'نW،VB.netوCC#a7! .:4+cאH'$Cً]'نQ وCًj 3ًJ1Ih$%'و7Q1@אONو− لK7N אhFD iH, אe'ل و7N3 gN3 K ، GP אo] 53 i'د%'\ א'אد א− .RRbiH'VlH$V\iH,9و_אCs وאK7C5DHWQop\!ذ03و،S'د%و 15 ﻣﺤﺘﻮﻳﺎت اﻟﻜﺘﺎب אWS ، X'لوא'אVO א53 د$D4D .net 2008 ًא$Q$ و.net _D hC 53 D'F XPא אWS MQ :S%'3 XP אG 5D hس وgO وאXP אhQ') 5D 3$73 :' 53 ^C @ Xא אWS : אولXא ..O9وא `'אلO א53 + KFR zא אWS ¤'د7Q net 2008. _D U ق1 אC$ NS : ^ אXא .O+\אhאHא$bאY.ZאO'وאولوQ'د 5DiWiViH'VدQ،net._DU ق1אnD¤OR*VXאאWS:^אXא @ Xא אWg! K. 53 ً 43 5P _ ذא، net. _D مR. אiHوM N7 }H t אi$Q$ אhN7א .a7!$Q$אضא9A'ًVV .O+\אSbNDوjאnet.JSO\ًObو${NS:0אאXא 4z$אOXאאWSضQ،אFVU ق1א01NS53 :@3אXא .bא4אJVisual Studio_DU ق1אO53و C iH'V :%'3 Xא אWS ، g O א وq אbND אضC$N NS : אدسXא .Y!ZRFqאG] Wa7!'SوYj$F .ً3$73iH'V5PאوXHאFא:0אXא OوgQ')وhJOאnDfאNP> OOP:%'אNj4I$3'SlWS :53^אXא .k I53KFא .4אUg3א$+وאgVjVIوInterfaceshg%א'א:0אXא .gR7Nوg3O'دوPאU¤z1ICصN.אK%C53XאאWS:,אXא 16 NאUiHP\אg3א$+ وאCOLLECTIONS'אعאلCKVOXאאWSدQ :TDدLאXא .O+\א _DUو4אqUً3$7^CbNDnDf،i\אlWS3$7\א4 א:TD^אXא .net. .hO\א03K3אOوO+\אجאIلوאIقאد:TD^אXא *jV وאgQ' t אh وאدوאWINDOWS FORMS _ אلD U ق1 א: TD 0 אאXא .:! Iوאو .+GDI لI53אدjNh3'_אDUQHU¤WI]Q:TD@3אXא .O+\אgوאgدوאCو אدوjNh3'V+\אWPFN7Qא$:TDאدسXא 3 وADO.net لI 53 h א$D'א. _D U ق1 אNP> Xא אWS U : TD 0 אXא .:! IوSQL Serverhא$D'א.53مذQ .NSgz$אNP>LINQو'! مPQ353i$Q$אN7א:TD53^אXא .0QHT\אiHدא9!'وPQ353i$Q$אWWFN7_DUא$NS:TD0אXא .!'وPQ353h71وא23א4אHT\WCF_D03ًMQC:ونTאXא K. O+\ אig%9 אnD KqT 3k א0s א\'א53 D'F : ونTد وאL אXא . אXאUGQ'_אDU ق19א .ASP.net لI53DOGQوh71Q'153XאאWSNP>، IאXא:ونTא^وאXא ...0ONوאi$jOאgQ')U'نPQنCא53'%HC 17 ﻟﻤﻦ ﻫﺬا اﻟﻜﺘﺎب A'3f$gQ9XPאאWg!،XPאאWSKFDUH'אT3'אلNGbאSאلpאאWS%א ً نQC Q1ول אC nD MQ و، iS ن زK 53 @7Q نC ولd'g! ، N3 JO ً VV @ وY3 .¤'א3 !3 OP! ً !Z) N ' 3C ، 4 אh} אH s' אوXP אX ًא !]'אz$3 N !¦ذא ق1א17'نPXPאאWg!ً1'3N'3C،ONSH§tאXא'אU ق1وאa7!$Q$א ..net 2008_D53!وعi$DUi$% ،hאUًb'VIsא'אs'وC،XPאUhאHאPאi^53fZ[אK>9نC'%HCאW i\אSlWSذא3C،:N3SSאQtطא7NאUًאH'!'لI$طאوא7N{وزא:NP> SN'لאوVOא،XPאhQ')53ًJ,h'O9CولR!4_אDU ق1אو .ذ$z,KسC 53'نPtאXא'אs'g!،7אROVאUXPאhQ')nD01نCًא$%cFgQ g!(Nא$نC7אROVאh{وزN'ً M!אW.ًMQאfZRFوC،¨$FS{وزKMO\א .AICi3 18 اﻟﺘﻌﺮﻳﺐ K^3Uو،BZאizא.03مאא$D03ًD'$%CN–gCوC–אqgC.tאGPאKU H$.وWאX''אSאWSو،Q<אqb9אFP אnDא عKM!אNh9LאlWS .XPאאWS5Fs:%gعא1\א LoopsوConditionstFPBZHאPאh7وTאKFאK^3،Jو$9hBZא¤NS אلoQ( وJ!) :C nD Class אلoQ K^3 J $ 9 gNP وi'د% K.C و$ }H hB ¤NS ، ذi אدU $` L אlWS U ، אWPS وVariable ً لQ$ q\ א، (g% )وאgC nD Interface !:! Iא(و...h3$g\א،hא$T\)אK^3B3C،i3KUSذ5Dً Q$i$وאi3BZא .7وא3$ًN3:QCH3a7!3$+א،gg3$+و_אggא nDدFD9ولא9ًMQC،نP3CUkbאFPذאQ_DF${5¦KnDو GCBnDXPאYقO9א53א'ع$%'Q9(RאnR!،IDXizא.UtB .4אhR1V3B5DقOאUE$RنC5Dً M!'3'PאhR1V3 اﻟﻔﻬﺮس 19 29 31 32 33 35 37 38 39 41 42 43 45 47 48 49 50 50 52 52 53 54 55 56 56 58 58 59 60 60 63 65 65 66 68 68 69 2008 ﺗﺤﻤﻴﻞ ﻧﺴﺨﺘﻚ اﻷوﻟﻰ ﻣﻦ ﻓﻴﺠﻮال ﺳﺘﻮدﻳﻮ: 02 اﻟﺒﺎب Visual Studio 2008 اﻟﻨﺴﺨﺔ اﻟﻜﺎﻣﻠﺔ ﻣﻦ.1 Visual Studio 2008 اﻟﻨﺴﺦ اﻟﻤﺠﺎﻧﻴﺔ ﻣﻦ.2 VS 2008 إﻟﻰVS 2005 ﺗﺮﻗﻴﺔ ﻣﺸﺮوﻋﻚ اﻟﺬي ﻳﻌﻤﻞ ﻋﻠﻰ.3 net 2008. اﻟﺠﺪﻳﺪ ﻣﻊ: 03 اﻟﺒﺎب SilverLight ﺗﻘﻨﻴﺔ.1 LINQ ﺗﻘﻨﻴﺔ.2 WPF ﺗﻘﻨﻴﺔ.3 Expression ﻣﺠﻤﻮﻋﺔ.4 WCF ﺗﻘﻨﻴﺔ.5 Code Refactoring .6 اﻟﺮﺋﻴﺴﻴﺔnet. ﻣﻔﺎﻫﻴﻢ ﺑﻴﺌﺔ: 04 اﻟﺒﺎب . net. ﻟﻐﺎت.1 . اﻟﻌﻨﺎﺻﺮ اﻷﺳﺎﺳﻴﺔ ﻓﻲ دوت ﻧﺖ.2 Base Class Library .3 net Assemblies. .4 CIL .5 Metadata .6 Mainfest .7 Common Type System .8 CTS Members .8.1 CTS Data Types .8.2 Common Language Specification .9 Common Language Runtime .10 Object Browser اﺳﺘﺨﺪام.11 Name Space ﻣﺠﺎﻻت اﻷﺳﻤﺎء.12 اﺳﺘﻴﺮاد ﻣﺠﺎﻻت اﻷﺳﻤﺎء.12.1 ildasm اﺳﺘﺨﺪام ﺑﺮﻧﺎﻣﺞ.13 Open Source .net ﻫﻞ ﺗﺒﺤﺚ ﻋﻦ.14 Visual Studio 2008 اﻟﻮاﺟﻬﺔ اﻷﺳﺎﺳﻴﺔ ﻟـ: 05 اﻟﺒﺎب ﻛﻴﻒ أﻛﺘﺐ اﻟﻜﻮد ؟.1 VS 2008 Command Prompt اﺳﺘﺨﺪام.1.1 Textpad اﺳﺘﺨﺪام.1.2 ++Notepad .1.3 SharpDevelop .1.4 Viusal Studio 2008 اﻟﺒﺪاﻳﺔ ﻣﻊ. 2 20 .1.2ﺑﺮﻧﺎﻣﺠﻚ اﻷول اﻟﺒﺎب : 06ﻣﻜﻮﻧﺎت اﻟﻠﻐﺔ اﻟﺮﺋﻴﺴﻴﺔ ﻓﻲ net.اﻟﺠﺰء اﻷول .1ﺧﺼﺎﺋﺺ Console .2ﺗﻌﺮﻳﻒ اﻟﻤﺘﻐﻴﺮات .2.1أﻧﻮاع اﻟﻤﺘﻐﻴﺮات .2.2اﻟﺜﻮاﺑﺖ Constants .2.3اﻟﻘﻴﻢ ﻟﻠﻘﺮاءة ﻓﻘﻂ Read Only Dield .3اﻟﻤﺘﻐﻴﺮات اﻟﻨﺼﻴﺔ String .3.1اﻟﺨﺼﺎﺋﺺ واﻟﺪوال اﻟﺮﺋﻴﺴﻴﺔ .3.2ﺗﻘﺴﻴﻢ اﻟﻨﺼﻮص .3.3دﻣﺞ اﻟﻨﺼﻮص .3.4ﻣﻘﺎرﻧﺔ اﻟﻨﺼﻮص - Escape Characters .3.5ﺳﻲ ﺷﺎرب ﻓﻘﻂ .3.6اﻟﺘﺤﻮﻳﻞ ﻣﻦ وإﻟﻰ اﻟﻨﺼﻮص StringBuilder .3.7 .4اﻟﺘﻌﺎﻣﻞ ﻣﻊ اﻟﺘﺎرﻳﺦ واﻟﻮﻗﺖ .5اﻟﺘﺤﻮﻳﻞ ﺑﻴﻦ اﻟﻤﺘﻐﻴﺮات اﻟﻤﺨﺘﻠﻔﺔ Widening Conversions .5.1 Narrowing Converstions .5.2 Cast .5.3 Convert.To .5.4 .6اﻟﺠﻤﻞ اﻟﺸﺮﻃﻴﺔ ﻓﻲ دوت ﻧﺖ .6.1أﺳﺎﺳﻴﺎت اﻟﺸﺮوط .6.2دﻣﺞ اﻟﺸﺮوط AndAlso .6.3 OrElse .6.4 .6.5اﺳﺘﺨﺪام switch .7اﻟﺤﻠﻘﺎت اﻟﺘﻜﺮارﻳﺔ For - Next Loop .7.1 While Loop .7.2 For Each Loop .7.3 اﻟﺒﺎب :07ﻣﻜﻮﻧﺎت اﻟﻠﻐﺔ اﻟﺮﺋﻴﺴﻴﺔ ﻓﻰ - .netاﻟﺠﺰء اﻟﺜﺎﻧﻰ .1ﻟﻨﻔﻬﻢ ﺑﺮﻧﺎﻣﺠﻨﺎ اﻷول .2اﻟﺪوال Function .3اﻟﻄﺮق Methods .4اﻟﻮﻇﻴﻔﺔ out .5اﻹرﺳﺎل ﺑﺎﻟﻤﺮﺟﻊ byrefواﻹرﺳﺎل ﺑﺎﻟﻘﻴﻤﺔ byval 71 73 75 75 77 77 79 80 80 81 81 81 82 82 83 85 86 86 87 87 88 89 89 90 91 92 93 94 94 95 96 97 99 103 104 104 106 21 .6اﻟﻤﺼﻔﻮﻓﺎت .1.6ﻣﺎﻫﻰ اﻟﻤﺼﻔﻮﻓﺎت Arrays .2.6ﺗﻜﻮﻳﻦ اﻟﻤﺼﻔﻮﻓﺎت .3.6اﻟﻤﺼﻔﻮﻓﺎت ﻣﺘﻌﺪدة اﻷﺑﻌﺎد .4.6ﻋﻤﻞ ﻣﺼﻔﻮﻓﺔ ﻣﻦ اﻟﻤﺼﻔﻮﻓﺎت .5.6إرﺳﺎل وإﺳﺘﻘﺒﺎل اﻟﻤﺼﻔﻮﻓﺎت ﻣﻦ وإﻟﻰ اﻟﺪوال .6.6ﺧﺼﺎﺋﺺ اﻟﻤﺼﻔﻮﻓﺎت اﻟﺮﺋﻴﺴﻴﺔ .7اﻟـ Enumeration .8اﻟﺘﺮاﻛﻴﺐ Structure .8.1إﻧﺸﺎء اﻟﺪوال داﺧﻞ اﻟـ Struct .9اﻷﻧﻮاع Valueواﻷﻧﻮاع Reference .10اﻟﻤﻘﺎرﻧﺎت Nullable Types .11 .11.1ﺧﺼﺎﺋﺺ اﻟـ Nullable .11.2اﻟﻤﻌﺎﻣﻞ ؟؟ اﻟﺒﺎب :08ﻣﻘﺪﻣﺔ إﻟﻰ اﻟﺒﺮﻣﺠﺔ ﻛﺎﺋﻨﻴﺔ اﻟﺘﻮﺟﻪ OOP .1ﻣﻘﺪﻣﺔ إﻟﻰ اﻟﻔﺌﺎت Classes .1.1اﻟﻤﺸﻴﺪات Constructors .2.1اﻟﻤﻬﺪﻣﺎت Destructor this .2 .3اﻟﺘﻌﺮف ﻋﻠﻰ Static Static Class .3.1 .4إﻋﺎدة ﺗﺤﻤﻴﻞ OverLoading .5ﻣﻌﺮﻓﺎت اﻟﻮﺻﻮل Access Modifier .6اﻟﻌﻨﺎﺻﺮ اﻷﺳﺎﺳﻴﺔ ﻓﻰ OOP Encapsulation .6.1 Inheritance .6.2 Ploymorphoism .6.3 Encapsulation .7 .7.1إﺳﺘﺨﺪام دوال Publicﻟﻠﻮﺻﻮل إﻟﻰ ﻣﺘﻐﻴﺮات Private .7.2إرﺳﺎل اﻟﻘﻴﻢ ﻛﺠﺰء ﻣﻦ اﻟـ Conctructor .7.3إﺳﺘﺨﺪام اﻟـ Type Property .8اﻟﻮراﺛﺔ Inheritance .8.1ﺗﻌﺮﻳﻒ ﻋﻼﻗﺔ is-a .8.2اﻟﻜﻠﻤﺔ اﻟﻤﺤﺠﻮزة sealed - NotInheritable .8.3اﻟﻮراﺛﺔ اﻟﻤﺘﻌﺪدة .8.4اﻟﺘﻌﺪﻳﻞ ﻓﻰ اﻟﻜﻼس اﻟﻤﺸﺘﻖ 107 107 108 109 110 111 112 112 114 116 118 120 125 126 127 129 131 134 135 135 137 140 141 144 144 145 145 145 146 147 148 150 152 154 155 157 157 158 22 158 159 161 161 162 164 165 167 167 169 171 174 197 180 183 185 185 186 189 190 192 193 193 193 194 197 201 203 203 206 206 208 211 213 215 216 218 219 has-a اﻟﻌﻼﻗﺔ ﻣﻦ ﻧﻮع.8.5 Casting اﻟﺘﺤﻮﻳﻼت.8.6 is اﻟﻜﻠﻤﺔ اﻟﻤﺤﺠﻮزة.8.7 Visual Studio Class Diagram .8.8 Polymoriphism اﻟـ.9 Abstract اﻟـ.10 Abstract method .10.1 اﻟﻮاﺟﻬﺎت- Interfaces : 09 اﻟﺒﺎب Interface ﺗﻌﺮﻳﻒ اﻟـ.1 Names Clashes .2 IEnumerable interface .3 ICloneable interface .4 IComparable interface .5 اﻷﺧﻄﺎء واﻗﺘﻨﺎﺻﻬﺎ:10 اﻟﺒﺎب Syntax Errors اﻷﺧﻄﺎء اﻟﻨﺤﻮﻳﺔ.1 Logical Errors اﻷﺧﻄﺎء اﻟﻤﻨﻄﻘﻴﺔ.2 System.Exception اﻟﻔﺌﺔ.3 Throwing Exceptions - رﻣﻰ اﻻﺳﺘﺜﻨﺎءات.4 Catching exceptions - اﻗﺘﻨﺎص اﻷﺧﻄﺎء.5 Finally اﺳﺘﺨﺪام.5.1 break اﺳﺘﺨﺪام.5.2 TargetSite اﺳﺘﺨﺪام.5.3 HelpLink اﺳﺘﺨﺪام.5.4 ﻋﻤﻞ أﺧﻄﺎء ﺧﺎﺻﺔ.6 Collectiona اﻟﺘﺠﻤﻴﻌﺎت:11 اﻟﺒﺎب System.Collections ﻓﻰInterfaces اﻟـ.1 System.Collections اﻟﻔﺌﺎت ﻓﻰ.2 ArrayList .2.1 HashTable .2.2 Queue.3.2 Stack .4.2 .net 2008 اﻟﺒﺮﻣﺠﺔ اﻟﻤﺘﻘﺪﻣﺔ ﻓﻰ:12 اﻟﺒﺎب Generics اﻟـ.1 Structure and Class Generics .1.1 Generic Collection .2.1 Where T اﺳﺘﺨﺪام.3.1 Delegates اﻟـ.2 23 221 223 225 226 227 228 229 232 235 237 238 238 240 243 247 250 250 252 253 255 259 259 261 261 262 263 264 264 265 265 270 271 272 272 273 274 277 Delegates ﺗﻌﺮﻳﻒ اﻟـ.2.1 Events اﻷﺣﺪاث.2.2 C# ﻓﻘﻂ ﻓﻰ- Anonymous Methods اﻟـ.3 اﺳﺘﻨﺘﺎج ﻧﻮع اﻟﻤﺘﻐﻴﺮات.4 Extension Methods اﻟﺪوال اﻟﻤﻤﺘﺪة.5 Automatic Properties .6 Lambda Expressions ﺗﻌﺒﻴﺮات ﻻﻣﺪا.7 Object Initializer Syntax ﺻﻴﻎ إﻧﺸﺎء اﻟﻜﺎﺋﻨﺎت.8 Anonymous Types اﻷﻧﻮاع اﻟﻤﺠﻬﻮﻟﺔ.9 Partial Methods .10 Gerbage Collector .11 GC اﻟﻔﺌﺔ.11.1 Operator Overloading .12 Pointers اﻟﻤﺆﺷﺮات.13 Query Expressions .14 Preprocessor Directives .15 #region , #endregion .15.1 #if , #elif , #else , #endif .15.2 #define , #undef .15.3 XML Commenting .16 .net assemblies .17 namespace اﻟـ.17.1 Default Namespace ﺗﻐﻴﻴﺮ اﻟـ.17.2 Format of a .net Assembly ﺷﻜﻞ ﻣﻠﻒ اﻷﺳﻤﺒﻠﻰ.17.3 Private Assemblies .17.4 Shared Assemblies .17.5 Multithreading اﻟﻤﺴﺎرات اﻟﻤﺘﻌﺪدة.18 ﻣﻘﺪﻣﺔ.18.1 Synchronization اﻟﺠﻮرﻳﺰﻣﺎت اﻟﺘﺰاﻣﻦ.18.2 System.Threading.Thread .18.3 Priority اﻷوﻟﻮﻳﺔ.18.4 ParameterizedThreadStart .18.5 Foreground and Background .18.6 Threads Synchronization .18.7 ThreadPool .18.8 BackgroundWorker .18.9 System.IO اﻹدﺧﺎل واﻹﺧﺮاج ﻓﻰ:13 اﻟﺒﺎب 24 278 278 279 284 284 285 287 289 289 289 289 291 292 293 294 296 297 298 301 301 303 305 307 307 310 311 315 320 320 321 322 323 323 324 325 325 325 System.IO اﻟﻔﺌﺎت اﻷﺳﺎﺳﻴﺔ ﻓﻰ.1 Directory وDirectoryInfo اﻟﻔﻮراق ﺑﻴﻦ.2 DirectoryInfo اﻟﻔﺌﺔ.3 Directory اﻟﺘﻌﺎﻣﻞ ﻣﻊ اﻟﻔﺌﺔ.4 DriveInfo اﻟﺘﻌﺎﻣﻞ ﻣﻊ اﻟﻔﺌﺔ.5 FileInfo اﻟﺘﻌﺎﻣﻞ ﻣﻊ.6 Open إﻧﺸﺎء وﻓﺘﺢ اﻟﻤﻠﻔﺎت ﺑﺎﺳﺘﺨﺪام.6.1 OpenWrite وOpenRead ﻓﺘﺢ وإﻧﺸﺎء اﻟﻤﻠﻔﺎت ﺑﺎﺳﺘﺨﺪام.6.2 OpenText ﻓﺘﺢ اﻟﻤﻠﻔﺎت ﺑﺎﺳﺘﺨﺪام.6.3 AppendText وCreateText اﻟﻔﺘﺢ ﺑﺈﺳﺘﺨﺪام.6.4 File اﻟﺘﻌﺎﻣﻞ ﻣﻊ اﻟﻔﺌﺔ.7 Stream.8 FileStream اﻟﻔﺌﺔ.8.1 اﻟﺘﻌﺎﻣﻞ ﻣﻊ اﻟﻔﺌﺎت اﻟﻤﺸﺘﻘﺔ.8.2 StreamWriter, StreamReader .8.3 StringWriter,StringReader .8.4 BinaryWriter,BinaryReader .8.5 FileSystemWatcher .9 Object Serialization .10 Serialization اﻟﺘﻌﺎﻣﻞ ﻣﻊ اﻟـ.10.1 XmlSerializaer .10.2 Windows Forms ﺑﺮﻣﺠﺔ اﻟﻨﻮاﻓﺬ: 14 اﻟﺒﺎب ﻣﻘﺪﻣﺔ.1 ﺑﺎﻟﻜﻮدWindows Forms ﺑﻨﺎء.2 إﺿﺎﻓﺔ أدوات ﺑﺎﻟﻜﻮد.2.1 إﺿﺎﻓﺔ اﻟﻘﻮاﺋﻢ.2.2 Visual Studio .net إﻧﺸﺎء ﻓﻮرم ﻋﻦ ﻃﺮﻳﻖ.3 Windows.Forms ﻣﺠﺎل اﻷﺳﻤﺎء.4 Windows.Forms اﻟﻔﺌﺎت اﻟﺮﺋﻴﺴﻴﺔ ﻟﻌﻨﺎﺻﺮ.4.1 Form ﺧﺼﺎﺋﺺ اﻟﻔﺌﺔ.4.2 Form دوال اﻟﻔﺌﺔ.4.3 Form دوال اﻟﻔﺌﺔ.4.4 Controls اﻟﻔﺌﺔ.5 Controls ﺧﺼﺎﺋﺺ اﻟﻔﺌﺔ.5.1 Controls أﺣﺪاث اﻟﻔﺌﺔ.5.2 System.Windows.Forms.Control أدوات.6 Button .6.1 25 326 326 326 327 329 329 329 332 333 343 343 343 335 336 338 338 341 342 345 346 347 349 351 351 352 354 355 356 357 361 363 363 363 363 364 365 365 CheckBox .6.2 RadioButton .6.3 ListBox وComboBox .6.4 Textbox .6.5 Label .6.6 Panel وGroupBox .6.7 RichTextBox .6.8 Timer.6.9 TreeView .6.10 ProgressBar.6.11 TrackBar .6.12 DateTimePicker .6.13 Dialogs .7 MessageBox .7.1 Dialogs Controls .7.2 ColorDialog .7.3 FontDialog .7.4 Open And Save Dialogs .7.5 PrintDialog .7.6 أﺣﺪاث اﻟﻤﺎوس.8 أﺣﺪاث اﻟﻜﻴﺒﻮرد.9 +GDI : 15 اﻟﺒﺎب +GDI ﻣﻘﺪﻣﺔ إﻟﻰ.1 System.Drawing ﻣﺤﺘﻮﻳﺎت ﻣﺠﺎل اﻷﺳﻤﺎء.2 Graphics اﻟﻔﺌﺔ.3 Pen .4 Bruch .5 رﺳﻢ اﻷﺷﻜﺎل.6 رﺳﻢ اﻟﻨﺼﻮص.7 Windows Presentation Foundation : 16 اﻟﺒﺎب ﻣﻘﺪﻣﺎت أﺳﺎﺳﻴﺔ.1 WPF .1.1 XAML .1.2 Microsoft Expression .1.3 WPF أﻧﻮاع ﺗﻄﺒﻴﻘﺎت.2 WPF ﻣﺤﺘﻮﻳﺎت وﻣﻜﻮﻧﺎت.3 WPF ﺗﻄﺒﻴﻘﻚ اﻷول ﻓﻲ ﻋﺎﻟﻢ.4 26 367 372 375 376 382 385 387 387 388 389 390 391 398 399 399 400 401 402 403 411 413 414 414 415 415 421 421 429 439 441 443 444 444 445 449 450 اﻟﺒﺪء ﻣﻦ ﺧﻼل ﻓﻴﺠﻮال ﺳﺘﻮدﻳﻮ.5 WPF أدوات.6 Data Binding رﺑﻂ اﻟﺒﻴﺎﻧﺎت.7 WPF 2D .8 WPF اﻟﺤﺮﻛﺔ ﺑﺎﺳﺘﺨﺪام.9 XAML اﻟﺤﺮﻛﺔ ﺑﺎﺳﺘﺨﺪام.10 Styles ﺗﻌﺮﻳﻒ.11 Style ﺗﻐﻴﻴﺮ ﻃﺒﻴﻌﺔ ال.11.1 ﻣﻦ آﺧﺮStyle اﺷﺘﻘﺎق.11.2 Triggers ﺑﺎﺳﺘﺨﺪامStyle ﺗﺼﻤﻴﻢ.11.3 Tamplates اﻟـ.12 WPF 3D .13 XNA .14 Microsoft Expression Studio .15 Microsoft Expression Web .15.1 Microsoft Expression Design .15.2 Microsoft Expression Media .15.3 Microsoft Expression Encoder .15.4 Microsoft Expression Blend .15.5 ADO.net ﻗﻮاﻋﺪ اﻟﺒﻴﺎﻧﺎت ﺑﺎﺳﺘﺨﺪام: 17 اﻟﺒﺎب ADO.net اﻟﺒﺪء ﺑﺎﺳﺘﺨﺪام.1 ADO.net Data Provider ﻣﻜﻮﻧﺎت.2 اﻟﻤﺪﻋﻮﻣﺔ ﻣﻦ ﻗﺒﻞ ﻣﺎﻳﻜﺮوﺳﻮﻓﺖData Providers ال.1.2 Third-Party ADO.net Data اﻟﺘﻌﺎﻣﻞ ﻣﻊ ﻣﺰودات ﺧﺪﻣﺔ أﺧﺮى2.2 Providers System.Data ﻣﻜﻮﻧﺎت ﻣﺠﺎل اﻷﺳﻤﺎء.3 Sql Server اﻟﺒﺪاﻳﺔ ﻣﻊ.4 إﻧﺸﺎء ﻗﺎﻋﺪة اﻟﺒﻴﺎﻧﺎت.4.1 Sql Statements .4.2 Stored Procedures .4.3 SQL Injection .4.4 اﻟﻌﻼﻗﺎت.4.5 اﻟﻮﺿﻊ اﻟﻤﺘﺼﻞ.5 ConnectionStringBuilder اﻟﺘﻌﺎﻣﻞ ﻣﻊ.5.1 Command اﻟﺘﻌﺎﻣﻞ ﻣﻊ.5.2 Data Readers اﻟﺘﻌﺎﻣﻞ ﻣﻊ.5.3 Data Access Layers .6 27 459 461 465 465 467 467 468 470 472 473 474 476 477 479 482 487 488 490 494 495 499 501 502 502 503 504 507 509 511 512 513 514 517 517 518 521 523 Asynchronous Data Access .7 Transactions .8 اﻟﻮﺿﻊ اﻟﻤﻨﻔﺼﻞ.9 DataSet .9.1 DataTable .9.2 DataTable اﻧﺸﺎء.9.3 DataColumn اﻟﺘﻌﺎﻣﻞ ﻣﻊ.9.4 DataRow اﻟﺘﻌﺎﻣﻞ ﻣﻊ.9.5 DataTable ﻟﻘﺮاءة اﻟﺒﻴﺎﻧﺎت ﻣﻦDataTableReader اﺳﺘﺨﺪام9.6 XML إﻟﻰSerializing ﻋﻤﻞ.10 DataGrid اﺳﺘﺨﺪام.11 DataAdapter اﺳﺘﺨﺪام.12 LINQ : 18 اﻟﺒﺎب . ﻣﻘﺪﻣﺔ.1 LINQ دوال.2 LINQ To DataSet .3 LINQ To XML .4 LINQ To SQL .5 SubmitChanges .6 ﻣﻦ ﺧﻼل اﻟﻔﻴﺠﻮال ﺳﺘﻮدﻳﻮLINQ To SQL اﻧﺸﺎء ﻓﺌﺎت.7 WWF : 19 اﻟﺒﺎب WF ﻣﻜﻮﻧﺎت وأﺳﺎﺳﻴﺎت.1 WF اﻟﺒﺪأ ﻣﻊ.1.1 Sequential Workflow .1.2 State Machine Workflow .1.3 WWF ﺗﻄﺒﻴﻖ.2 WF Code Library .3 WCF : 20 اﻟﺒﺎب Web Service .1 ﺧﺎﺻﺔ ﺑﻚ ﻣﻦ ﺧﻼل دوت ﻧﺖWeb Service ﻋﻤﻞ.1.1 ﺧﺎﺻﺔ ﺑﻚ ﻓﻲ ﻣﺸﺮوﻋﺎﺗﻚ اﻟﻔﻌﻠﻴﺔWeb Service اﺳﺘﺨﺪام.1.2 اﺳﺘﺨﺪام ﺧﺪﻣﺎت اﻹﻧﺘﺮﻧﺖ اﻟﺠﺎﻫﺰة.1.3 WCF ﻣﻘﺪﻣﺔ إﻟﻰ.2 WCF اﻟﺒﺪاﻳﺔ ﻣﻊ.2.1 Address ﺷﻜﻞ وﻣﺤﺘﻮﻳﺎت ال.2.2 ﻧﻘﺎط ﻣﺘﻘﺪﻣﺔ: 21 اﻟﺒﺎب Debug اﻟﺘﻨﻘﻴﺢ.1 28 526 528 533 535 539 541 548 553 554 557 558 558 561 564 567 572 572 574 574 575 578 579 580 582 585 591 591 592 593 594 ﺗﺠﻬﻴﺰ اﻟﺒﺮﻧﺎﻣﺞ ﻟﻠﺘﻮزﻳﻊ.2 #VB.net vs C .3 Mono ﻣﻘﺪﻣﺔ إﻟﻰ.4 ﺑﺮﻣﺠﺔ اﻷﺟﻬﺰة اﻟﻜﻔﻴﺔ ﻣﻦ ﺧﻼل دوت ﻧﺖ.5 ASP.net ﺗﻄﻮﻳﺮ اﻟﻤﻮاﻗﻊ ﺑﺎﺳﺘﺨﺪام: 22 اﻟﺒﺎب ﻣﻘﺪﻣﺔ إﻟﻰ ﺗﻄﻮﻳﺮ اﻟﻤﻮاﻗﻊ.1 ASP.net ﻣﻘﺪﻣﺔ إﻟﻰ.2 System.Web.UI.Page اﻟﻔﺌﺔ.3 Request .3.1 Response .3.2 ASP.net أدوات.4 اﻟﺨﺼﺎﺋﺺ اﻷﺳﺎﺳﻴﺔ ﻷدوات اﻟﻮﻳﺐ.4.1 MasterPages .5 Sitemaps .6 Validation Controls أدوات اﻟﺘﺤﻘﻖ.7 ﻟﺘﺨﺰﻳﻦ اﻟﺒﻴﺎﻧﺎتState Managment .8 Control State .8.1 ViewState .8.2 Session .8.3 Cookies .8.4 Application .8.5 Cache .8.6 Global.asax .8.7 وﻗﻮاﻋﺪ اﻟﺒﻴﺎﻧﺎتASP.net .9 DataGrid .9.1 WAP .10 WAP ﻣﺎ ﻫﻲ ال.10.1 WML .10.2 WAP + ASP.net .10.3 اﺟﺎﻛﺲAJAX .11 29 اﻟﺒﺎب 2 ﺗﺤﻤﻴﻞ ﻧﺴﺨﺘﻚ ﻣﻦ ﻓﻴﺠﻮال ﺳﺘﻮدﻳﻮ 2008 30 31 Visual Studio 2008 اﻟﻨﺴﺨﺔ اﻟﻜﺎﻣﻠﺔ ﻣﻦ .1 3P א+N א، !'وPQ3 0.'3 nD Visual Studio 2008 53 KFR 3 ¢ i$D $%'Q S${ ، a7! 'مQ 90 i$\ Q{ iH'V i'د%'3 gNP وiH'V 3 Professional Edition :aאאאWSnD رابط http://msdn.microsoft.com/en-us/vs2008/products/cc268305.aspx م$+Q23'SPower ISO 23*.isoo3KP,nD'نPaאאאWS53gFQtא+Nא .gصאص7'دא%و53$9وgFQtאhO\אU DVD وC CD 'د%وi[ :NS53 Power ISO 23KQNNP> رابط http://www.freedownloadscenter.com/Utilities/Backup_and_Copy_Utilities/PowerISO.ht ml :aאאאWS53!'وPQ353product keyאلG1.،3Pא+N.ZאUGNذא رابط http://msdn.microsoft.com/en-us/vs2008/products/cc263903.aspx HI . 53 و، Visual Studio 2008HI . وAdd or Remove ProgramsHI . 53و .:H!'وPQ33.Wאproduct keyلאلIد....Change/Remove 32 Visual Studio 2008 اﻟﻨﺴﺦ اﻟﻤﺠﺎﻧﻴﺔ ﻣﻦ .2 aאאnDًBS${ ،5QH'1Fً'لMQ'!א، !'وPQ3S!'tא3Pא¢N!sא :א رابط http://www.microsoft.com/express/product/default.aspx ^אKLא$gNP وProfessional Edition3Pא¢Nא53hP39אUK. אExpressאل¢NאlWS :אaאאUא¢Nא${،hو$אH'13K.53ً3א$+א 234א +Nא .net Q'1 J nD Basic אلX'] .net 2008 אل53 + http://go.microsoft.com/?linkid=7653517 Framework .net Q'1 J nD C# אلX'] .net 2008 אل53 + http://go.microsoft.com/?linkid=7653518 Framework .net Q'1 J nD C++ אلX'] .net 2008 אل53 + O+\אh71جא9م$+Framework http://go.microsoft.com/?linkid=7653520 zT9 iH'13 hدوאC !' .net Framework nD N3 Q'1 J 3$73GQوh71 http://go.microsoft.com/?linkid=7653519 gh$D'א.zT9+!'Q،H'gT\אhא$D'א.(م .net53א03K3א http://www.microsoft.com/express/sql/default.aspx 33 وאلgadgets אلzNFDKgtאi$Q$و'!אPQ3hدوאC$C mash-ups http://www.microsoft.com/express/popfly/default.aspx VS 2008 إﻟﻰVS 2005 ﺗﺮﻗﻴﺔ ﻣﺸﺮوﻋﻚ اﻟﺬي ﻳﻌﻤﻞ ﻋﻠﻰ .3 .:VjVI53iدO net 2008.nDKFnet 2005. لI53c\אDوT353+!NP> .i,3.Z©א3g(وnet 2008. لI53وعT\אO. • .NextHI. • >$7 א+N אªO 'دWن אP\ אHI . ، hO\ א53 א+ KFD HI . • .:!ًא .FinishHI. • .KFאzgא$zg9Q7nDKVRو،.Zאzgא • V *jV אKQ$ ، 2005 03 ً 7!'א3 زאل9 :NP و2008 لI 53 KFQ DوT3 ( !¦نR אn :אh'א1.a7!2008037!'א3 .وعT\*אjVIHI.Solution Explorer53 • .ONOption InferHI.CompileGQ'א53 • .net Framework V Target frameworkHI. Advanced Compile Options53و • ..net Framework 2.0.53ً9$3.5 tאhאH}!א.وعT3אU، 200803ًj7$%'tא0%!א\אsאD'نPאن .'1\א0%!א\אs.وReferencesل79.،S$Q 34 35 اﻟﺒﺎب 3 اﻟﺠﺪﻳﺪ ﻣﻊ .net 2008 36 37 ً7z$'دאCSאو17Nא،Y3SY17אضZ!אnD$DXPא53zאאWSU hN7 א5D .' אXא אWS U E$RN ، אوiF 234 _ C ^ א17N א، .net 2008 XאאWShRObG7نC¤ MQ5!אسUً435P_'!، .net 2008Uhg&tאi$Q$א .אXi,31N t אhN7 אK K .net 2008 03 hg& t אi$Q$ א3 אhN7 אa7! @ Xא אWg 'دV7\א USHو$g,tوאa7!hN753.net FrameworkKFDHאKIدאK3PאD$אn7Rbא .3د.وسHدU:Df!א4_אDU$Q$א3C،ً79VON3وسHد SliverLight ﺗﻘﻨﻴﺔ .1 %''NPوאN7 لאUjאO\אGCe)و3و'!אאPQ3h53z` tאh71K^3CKRGQ'شאDnD Flashh)Hא7אiDوRF SilverLightN7 .אجI9لوאIقאدnDدFD9وאCR\אQ$F\مא$+ 53 ، g[ SQ'1 قU }H وC − 1 Flash ¤[ P\ אAdobe , C نC $ }Hو Adobe,hZ,אWN3QHW%h אq$gTQ_W! شא¤[0QאQ'1אUghC$−!H$Q kوC، Action ScriptnD$Fh)E אنAdobeTb]!، MacroMedia,53:.'7 لI53!N\אaInDSun,IدF!،ApolloN7ً אICوFlexN753وFlash'SSg,Cو אلFQ 17N'ن אP }H و، QgN אU NRV3 U GVN $] אWS وJavaFX Script g`N3 _FD$nDt وאHD Video.$אD'Q$!KqT:FD$ شOאh).5D SliverLight .−3'3GnD−$אא¡لWS'لIدgN3,ول :SliverLight0.'3iHQزz%אN7אlWS5D$Q\א5Df رابط http://www.microsoft.com/silverlight/default_ns.aspx hאH$.وhP3`אS$C$، Get SliverLight'عs'\אaאא53 SliverLightKFR.Qא$ .SliverLight 38 SliverLight hP30Fوא،AICi30.'\`א.53و،: SetupKFDو234אKFR. .قOאª9و... :SilverLightN7nDًMQא$Ftאوא0.א\'אX% 0.'\א iH'b http://silverlight.net/samples/1.0/Page Turn/default.html /http://www.yeejie.com/silverlight_magazine LINQ ﺗﻘﻨﻴﺔ .2 z% م9אKQ'N7אlWS،hא$D'א.لU!'وPQ353i$Q$%N7 .4אq لI53i,3iH'VhNjP'لوא7Lאولوא$א03K3אQ}4אq53 :lWS م9אBאضZ!א5P>0Q^لF SQL Server Select companyname from customers ﻛﻮد U م9 א2 ${ 5P و، NNQ 3 אWS @ ... 7Q אم א$+ SWON Q NP> I א مKF ، gzא. 01 ، izא7 א7Q G ً ^3 RS.Fields("FieldName") :Qאد7Q15jPאURא53وizא7QدDLoopKFDNP>،$Q$%53izא7א 39 C# do { Console.WriteLine( Rs.Fields(“CompanyName”)); } while(Rs.Read()); ﻛﻮد VB Do While(Rs.Read()) Console.WriteLine (Rs.Fields("CompanyName")) Loop ﻛﻮد KP,nDg3K3אQhא$D'א7!אن3C،hא$D'א.03K3v\אHI9'אSאWSن KIدא533אאWSضZON،gbI Operators k وfunctions وmethods وMembers k Clases .i,3 .net אل C# var queryResults = from cust in customers _ select cust.CompanyName ﻛﻮد VB Dim queryResults = From cust In customers _ Select cust.CompanyName ﻛﻮد gzא.P3bאtאk'7وgVjVIki,3JO queryResults03K3אP3bوאنא .KVON7אlWS5D9XUfN،i,3 . WPF ﺗﻘﻨﻴﺔ3 Windows presentation لHVIאSوH'NאSH'g&WinFx$g,tאi$Q$אhN7א53i$وא אدnوCjNhg%א'אob'م$+qSوXAMLSAIאN7nD$Ffoundation ًMQ אP3 K(Q F!، QH'! iH'V XAML 'د$' Q net 2008. لI 53 WPF nD FD zN א، 40 hROb U E$d نF 'د אدP وאXAML אلY K3P אKVO אQ . hدHC نXAML X Pא .GQ'א ؟WPFאم$+\ذאא FV א23 א53 3 H'g& د. XAML אم$+ FV אY و4 אq Y K3P אKVOא U'دPאGP! شوnDאو،X',''!nDFVOK§،XAML'د$'tאVV+\א nD FVאFאN'v5P_tאFVאi'.وPRא53ًא$Q3RNFאWS@א، net. t אiSم אL א53 D'F $` ً MQ א، FV'د و@ אP א3$ ً b אFV\ אVisual Studio .234אg(3YوKF{nD¤$D ،net framework 3.5.K.9אnDوCnet 2008.KFRF.$]]!N3ً3Nذא،QgNאK. ج9 }H ، Q$7 אhg% א'אY وgN قO א$S, و، ^3 אlWS nD عKSp3 ]! אW 'ل3'gO3 q א7 و، H'V אو ذج אi'د%'\ אhS'Q$O אnD 0 אa7! 234 אKF :$אhg%لא'אB 0.'\א iH'b http://blogs.msdn.com/tims/archive/2007/02/02/ great-wpf-applications-6-fnac-com.aspx http://blogs.msdn.com/tims/archive/2007/03/05/ great-wpf-applications-12-roxio-central.aspx 41 http://blogs.msdn.com/tims/archive/2007/02/09/ great-wpf-applications-8-notescraps.aspx Expression ﻣﺠﻤﻮﻋﺔ .4 53l شאوOوאCX',''OאnDg%א'אFV\'مא7Q،FVאFDUً .zאH'א$N Flash لI53hLوא3وא9אوא،ROVאUgsووH'Vא017ً79Q،FVא23א .4وאFVאFDYً3ً V!${،אWPSو...4وC.'\g753و ، h71 אFFV3 h%9 lQ'1 5D !'وPQ3 ND א1 Expression 'Q 'د03 אن و3C NP> XAML 'م ج 'د7Q !'وPQ3 אج53 FV 23 אم$+ אP3 אنbC .ً MQC Expression BLEND لI534אNP>F،i,371U:3א$+א − Lאhאp\وאH'VوאQ$F\אQ'1 BLINDS ،jHh710Hא03 MS Expression H$VQ $Q$,−وز$NQ'אh713$س9:%'3'S وDesign'S^א1א، −! ش234:Tא$Q$, 'Sو،ًא$%DA'}Zא0.'א3FVb אWEB אلK%'S^א، −X',''O:Tא Iא، XAML وAJAX D دK% א53 ًא$% 3$73 hP3 5P وMicrosoft FrontPage لH'1א . Expression Media :! I'وQ$OوאQ$\א03K3*V L c 0.'3 وC .'3 KQ' b אBlinds 'S gN ig, ^ א1א :234jא,TאSlWS،'gאQUًא3א:! Iوhאp\و 42 3. – N7 א0.'3 53 و'! א אوPQ3 0.'3 53 'مQ 21 i$\ Q{ + KF NP> N7אlWSnDfNF - .!'وPQ\ Parteners אلhTאA$א53N7אzאT!'وPQ3 .XPאאWSU79وسHد5FsVO3iH'V WCF ﺗﻘﻨﻴﺔ .5 אوhPTאnDz'א،لVא0sوUKFtא23א4مא$§tאi$Q$و'!אPQ3hN7A$אS lWg!FgM5Qزg%aH:!Q23אHVI...:! IووZP9א$Q4אh3$I`وN\אK^323א .ضqאאWkg%'3N7א K%א53i$Q$%N7!'وPQ3Nhz%، .net 03 Sockets J! و6!`'אلU Winsock $ . Windows Communication Foundation لHVIאS وWCF لאV9אhFD K3P3و53 Server And Client دمIوKFD1KFD01HVI!،N7אlWS\ذא3C !!!'دPא53a7!1אiTD53K. لאI53 .hN7א.YوgNhH7Fق1f'WCF5DKVO\אNHدU،7אhN7א53عCgCF 43 Code Refactoring .6 53D'FSHVIiPOא،'Q`'אل'دO אصIDE אلgz%tאi$Q$אhאF\אA$ .:3K3אKg'دوP(אNnDi$D\אKj'א 5FM3 gN3 $ وאbC .net 2008 03 و، i$D3 23 אKP, nD 23א4 אlWS K^3 !' Q i אدU KQ$א،hJ!Uh אq\א23$،Hز1qM q\*jVIzTא53!s9אlWSNPe،sאZ!אiH'V .j3g%א'אWSK:! IوhאZ3HوאhJOאU qوא . Refactor! for Visual Basic 2008!`'אلK%234אאWSK^3AIC23א¤NSًMQא :aאאאWSnD'د%'3234א رابط http://msdn.microsoft.com/en-us/vbasic/bb693327.aspx :'دPאiW!nDgOMQtאh Q$אiH'blWSو bאlWSNPe، 2008UsאZ!אiH'VNFM3S وCode Snippet bIًMQو'!אPQ3!' 5P> Fj. 53 '1\ אFg\ אHI ذQ ، $ وא1 ون$ N3 F K3 אج 'دH אد53 K%א53:ً ^3$`!`'אلوK%א53234אאWSiود،i$Q$%!א'אدsوאg!Q$Rא :XH, رابط http://msdn2.microsoft.com/en-us/vbasic/bb973770.aspx 44 :234iH'blWSو bI gNP و، a7! 2008 ~ ً bI 39 !@ א2005 nD KF hאHא$b א¤NS ًא אذ ]نI @ ًא وIא .Visual Studio 200803ًsאZ!אNFM3אنRbא 45 اﻟﺒﺎب 4 ﻣﻔﺎﻫﻴﻢ ﺑﻴﺌﺔ .netاﻟﺮﺋﻴﺴﻴﺔ 46 47 .net ﻟﻐﺎت .1 53H\אאWSv...hqi$D:3$+.H35DiHDSK،i$وאq .net 49 hq U g. 1 אi$D. 'نP H\א אWS hT א53 $Q$ אN و2000 و'! 'א אمPQ3 K. 9وK@א\אONًאHو3gO%Zو،:OH$V\'دאPאk¦نhqאlWS0BF،4א 5Pو..3 Engine qא¤[9אh'P\אnDf'م7N...Vא7QUA'o§ .net .H3NtאhqאnDfNً . C++/CLI !s א، J#.net ،VB.net ، C# M t وאgON !'وPQ3 SH$V t אhq א$! n ''ل و، Oل ودP K^3 .net QH3 D$ t אAI אhq א¤NS JScript.net ... ًאICو .DN1bאzWאh714LISP.net ..@PNאJ .net QH3D$Qً ^3 mono f، Linux JnDKFtאhאHא$bًאMQאnN9 אض9 }H VB.net ً 79 : MN ، C# 'S .net J 3$ 9 א2N\ ن א$7! QgN אU 5P 4 1.H X'9 א3ً3'Q:®$.D'F`F f# مFMאنאnN9 ،hqא0S$C$و7Q' .net .N7 :NSgNDh VOא03QH\אlWSD$tאhqאKFnD ع9אQgNאU01 رابط http://www.dotnetlanguages.net/DNL/Resources.aspx اﺿﺎﻓﺔ :XU Pro C# 2008 .NET 3.5 Platform -Exploring the .NET universe using curly brackets QgNאUًB''אRدאم3 .net hq53د$אאWSK\ذא،:DG®ًو9¯GPאv1Q :Xאi$אא¯لWSnDG®وmaneged code ؛XPאX'אKMOQgM!،g'dوg'ن4Qtאqًא$%YY4\א53$Q$ אنא− nN9، Visual Basic hq Syntex K^3izא7.^אX'9אIאאKMOQF!...'אس.وא 48 وBasic وC# 4\5P> .net 03KFY4\א0BXW%و)و7Q'אHو$אNS 0F`!sאKgאgNk7אK®3אWSو،i$وאVN3ًBKF אDelphi وFortran وC++ .i$(وא3Y4\א 'ن4QY43$א'אQOאU${אن5P>،iد$3hqY43$א'אQOאHT3 − OQאWS،q@אONY4\'نאPQאنKMO\א53אنن$QgNאU$وא2N3אجIאQوhqi$ .Y4\אHIאUhTمא3^ אًאhאHI9א sQאhFאUihq¤NSً ^F!،g3א$+9سNא1Mi'.ط7NFhq א− 01אWPS...LאhFא\وאh 3אUًMQאi''لPא،אنH'OאK^3h9وא\د .net .JgM03ًBg$وhאF\אlWS53iدO9א .net اﻟﻌﻨﺎﺻﺮ اﻷﺳﺎﺳﻴﺔ ﻟﺒﻴﺌﺔ .2 hN7אlWS، .net JnD$F\א234אiiHدوUPRjHbNDE gY .net م$7 . : CLR, CTS and CLSz]ًאHVIאk3QE ^א :Fg3، Common Language RuntimeلHVIאSو،234 Runtime Layer אلCLR אلK^e U h אq\ و` א− وאل$ وאhP\ א.net - K j אh'P\ א'אع وאU PR אS 9א $Q$,HVI"،ن3אhאHVI!אsאWON وאthreads אل،g3K3وאiאWא7وiאWא .'3'Pزאg%nDSWON و.net 3وאCBZ9 א\אCLR אلKPT 3'D$\ אh א'אع א03 K3 * CTS X lHVI אQ W وאCommon Type System אل U3'D$\'אع א9'دא%وiDא303،gMYوgNK3אQoو، .net J5FsKF Common Language S وi I א3C ، AIC وJ Y h! I אg $%' t وא.net hJ 0B 3'D$\وא7אhא'אعא03a7!K3Vg! CLS 3SHVIאQtوאSpecification . .netJhאHא$bא0B53 'S CLS U \ א'אع אa7! م$+Q^ ً و3 C# אم$+ FV\ א234'ل אن א7 אن01 אWgو جHI%I'3א، mono lF\ אLinux nDKFאK%א53 .net Q@'زOnDKFً3e!'א3 .O+\אF(אKUizOP@אONSWONQאن5FM5! CTS CLSقאل1 49 Base Class Library .3 وאل$وא3אوאnD'd ClassJ!5DiHD'Sو، Base Class Library fQ3 .net N7!' ،7Q1@אON:VjVI03و:3K3אQ و.net hJ0BU'د%'3 JO אlWS، .net JUjא GUI אل، XML אل، Threadsאل،hא$D'א.وhO\א03K3אK^39אbNאClassאلMQ tאhqא53C03K3PK.و.KgCو$'34אX'אK%UP\אlWSSو.:! Iو ..netD$ :!'وPQ353 BCL אلhQ')ول$אאWS אلnD ً MQ' אd ، .net h71 Q'1 :% 3 K nD System 'd ، Q BZو zلאS System אن${$Q$,HVI،א..LאhF9وאلא$ وאDatatypes .hJOא.nDg'tوאjא ob'א JOא SWON'אدو9אPbI System.CodeDom . Lists, Stacks K^3'אع9א53د$DnD' System.Collections Process وאلCounters وאلEvents אلMQ System.Diagnostics 53 O ( nD KqT Q System.Globalization .:! IوF.9אhאدא$D9وאhqא Q5Dz'אhلא7ضوאQ3K '3'P אW!N3 Q 5D אو، hא$¡ وאhO\א Serial PortאلK^3 System.IO 50 KFDQ،234אoVt אResources אل System.Resources א\^لKnDhqאiد$3h71 'صVNא03K3Q3K System.Text RegularExpressionsאل03K3א System.Text.RegularExpressions .Net Assemblies .4 U'لRQ'دP!¦نא، .net h71zN:3$+W אCompiler وאل4אqFg3وQgNאU :sوQو، metadata !אلs9 IL ًאHVIאfQ3'S وintermediate language لQgNא dll KP,nDوC exe KP,nDz'אi,3KFK.אo3U لHVI C 7 !אsאF!אن3א،!'وPQ\HVI אMS وאلMSIL IL K3Qًن7 .7 אMS 53ً9$Common nD'R! metadata אل3א،:,3وא'אدو234אg'م7Qtمאg\ אMSIL وאلC IL אلK^> وאلIL אلMQ W א:O 9 אo3 ، U g3$+ אt אhJO א'אع وא0F obو ${ h9 ¤NS ، D'F¡ אlWk ً MQ אmanifest !s אQ ، ً MQC metadata X :Ob وQ metadata Ua7!$ وאmanifest A'Q$'نPQ5LאlWSUو،אo353^ً13g! .אgM03hO\אaHوQא$אKF'م7QgN3$وא CIL ال .5 Pro.CSharp 2008X53 C# q234אאWSضZON C# // Calc.cs using System; namespace CalculatorExample { // This class contains the app's entry point. class Program { static void Main() ﻛﻮد 51 { Calc c = new Calc(); int ans = c.Add(10, 84); Console.WriteLine("10 + 84 is {0}.", ans); // Wait for user to press the Enter key before shutting down. Console.ReadLine(); } } // The C# calculator. class Calc { public int Add(int x, int y) { return x + y; } } } :'دאPא$`ILDASMK^3GN31Cאم$+'دPאאWS5D2Nא9אOF.' ﻛﻮد .method public hidebysig instance int32 Add(int32 x,int32 y) cil managed { // Code size 9 (0x9) .maxstack 2 .locals init (int32 V_0) IL_0000: nop IL_0001: ldarg.1 IL_0002: ldarg.2 IL_0003: add IL_0004: stloc.0 IL_0005: br.s IL_0007 IL_0007: ldloc.0 IL_0008: ret } // end of method Calc::Add א\אUذQ،Platform-Specific Instructions'دPאKQ'Q_،\אlWSn ز و(مg אhP39 GN3 'د2N'د אP אBZ 'م7Q W وאJitter fQ 3 لI 53 .234א:DKFQWאKqTא :!'وPQ353aאאאWS53'عs'\אאWS5D$Q\אnDfאP3 رابط http://msdn.microsoft.com/en-us/library/f7dy01k1(VS.80).aspx 52 MetaData اﻟـ .6 ::! Iوhg%ووאhJ!دوאلو53'دPאhQ')Kob'م$+t אMetaData nD^ل3 ﻛﻮد TypeDef #2 (02000003) ------------------------------------------------------TypDefName: CalculatorExample.Calc (02000003) Flags : [NotPublic] [AutoLayout] [Class] [AnsiClass] [BeforeFieldInit] (00100001) Extends : 01000001 [TypeRef] System.Object Method #1 (06000003) ------------------------------------------------------MethodName: Add (06000003) Flags : [Public] [HideBySig] [ReuseSlot] (00000086) RVA : 0x00002090 ImplFlags : [IL] [Managed] (00000000) CallCnvntn: [DEFAULT] hasThis ReturnType: I42 Arguments Argument #1: I4 Argument #2: I42 Parameters (1) ParamToken : (08000001) Name : x flags: [none] (00000000) (2) ParamToken : (08000002) Name : y flags: [none] (00000000) 'م7 אن.net nD KF وאNP> ، ^ل3 ولC U :P NF. W'د אP אob' אz'م א7Q nDو$אKQ$ً3'Qج5}H:א$7Dא،gOvTوRsطوא7NאGא،'دPאאWSnD ع9 .o\אאWS Manifest اﻟـ .7 o\אאWSoVQ، Assembly File 53^א¤NS'نn23KPo\אאWS53a7!i$ وא+ ^ل3אWS،o353^'دא%وUjא9אo3و9א+.H53:O9א :D'NאlWS53'دnD 53 ﻛﻮد .assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) .ver 2:0:0:0 } .assembly Calc { .hash algorithm 0x00008004 .ver 0:0:0:0 } .module Calc.exe .imagebase 0x00400000 .subsystem 0x00000003 .file alignment 512 .corflags 0x00000001 Common Type System .8 JU3'D$\'אعא9אob'*: وذאCTSnDV+\'عאs'\אאWSUN Sא'אعlWS،אgM03g3Oو.net Class - Interface - Struct - Enumeration - Delegate - سאصH$ لאIאنNQ3אن9،XPא53O3UgN3KoQ7QnDfN 3 אCTS אلi$j!53^ج\!א5!QدDh712343Nذא،g3 CTS אلK3O'SN nDf'ن%R! .netQ'1J5Fsq אوCompilerzN'ن3'7Q5QWאوאh'אدوא43 ClassnD ًאVً9^3]ذ،9*אjVא 54 ل:T א$Q$, − א 'دnD 'd 9 Abstract Class אل، Abstract Class fQ 3 ¤NS 'د1nD'd5:א:3א$+אUz$אK.:אHوKFDذ$5P>r interface Abstract Class fQ\^ل3אWS،$وא C# class abst_class { int sum(int x,int y); string name; } ﻛﻮد VB Class abst_class Private Function sum(x As Integer, y As Integer) As Integer End Function Private name As String End Class ﻛﻮد Q3'PאU CTS 03K3אUH'F!gجRt אCTS *אلjVIول$%5Fs53وאن Q$ نCTS HIאK.جR، Is the class abstract or concrete bא$`.ً ^3אص .ط7NאlWSK^}ًMQאl4§אنNSClass ﻣﻼﺣﻈﺔ في دروس قادمة سنشرح بالتفصيل كيفية عمل، ال تقلق لو لم تتضح لديك مثل ھذه الخصائص . وانواعه وطرقة المختلفةClass CTS Members .8.1 gN3K Members אل53د$D!אsאNP>، CTS لI53O+\א'אعאob'F.אن$ :ً MQ'نאPאن5P>، Fields 'ل7LQدDh אq3'نPאن5P> Members אل، constructor, finalizer, static constructor, nested type, operator, method, property, indexer, field, read-only field, constant, event ً ^3 Public 'نPQאن5P>،Q¯HA$3وC ( visibility trait) fQ3:Q$zMDאlWS53$وאK 55 אنfאنNSNNQ3،ًNوHد5Fsً79:DfN א.. ClassJOجאHI53:Q¯H5P>r . CTS UgOb'Q*jVאlWSK CTS DataTypes .8.2 Pro C# 2008 X53ول$אאWS، .net K.533'D$\ אDataTypes אلnDًMQ אCTS 'אلd :E ^א9 א.net hq keywords Ks'03 .net N3א\!א53'عN CTS אلi$j!3'\fدאنDh71234FFgQ3K אWS 53 z$ אNPF! ، CTS 5D $Q\ אnD f אU G وiPO` אD א$. N ذא3C ، 9א :aאא رابط http://msdn2.microsoft.com/en-us/library/zcx1eb1e.aspx 56 Common Language Specification .9 3א زh1\א53nאد$LאoV CTS אل53 subset S CLS אل،א%'\אUذF QHI אCTS hQ') !¦ن، I nN} و، .net J KF q אlWS 'ل אن7 א01N CLS UgF{ CTS hQ')53D'F،IאUS${9 و.net hqUS${אن5P> .Q'1 .net Jم$+qKPQH%'نאP م$+qKPg7153$9وgOb'Qو،QH%9وطאTאlWSnD CLS Rules 1V3א قQو .Q'1 .net J !אذא3P3، CLS אلgFMQ9t*אjVא53i D'F¤NS، VB.net وC# hqN !s لאI53KqTאF(C0BnDgFDiD\א9 אمCLSאل5Fs'د%'3:3$+W'دאPنא :CLS533وאCnDA''d9C'دWאzאnDC'دאPא ﻛﻮد [assembly: System.CLSCompliant(true)] :NS53izא7אb'א3NP> CLS 'عאلs'}ًFg3Nذא رابط http://msdn.microsoft.com/en-us/library/12a7a7h3.aspx Common Language RunTime .10 qزgאnD אص.net 'دאلKF'1\אh3'\!אM CLR !¦نאل،ً7ذF 1M3¦!!`'אل2343Nذא،א\^لGQ7و،b'دאPאgetאqא5D(Nא N '3א،jאh`'אلودوאOFV\אKFزgאnD msvbvm60.dll'د%' 'S CLR !¦نאل،7Q1@אONو...71:DKFWزאgאnD JVM !!¦ج%2343 .'3'زg%אnD .net JFV\א71KF:%Wא$'אo\א 57 Microosft Common ~ ًאHVI אmscoree.dll lF\ אCLR אلP3'د%' ج.net _אلDO! P\אlWS9אo3iH,אQא$03وz$03،Object Runtime Execution Engine U TypesK ً MQ אLoad KFQ ، metadata אلizא. و9 אo\ Load KF CLR 'م אل7Q F platform specific instructions CIL Ui'د%'\א234א3אوאBZ'م7Qً אIوא،H'F\א 'مאل7234אKFD لIو،WON CLR אلz$Qً אIא...¤زg%nDWONא:NPFً7N7Oא .Ug3$+N ذאBase Class Ui'د%'\ א.net K9אhJOא03K3CLR :lWON53 'دوnative :Q'n'دPאKא3s'QQ$PQو53a1+\אאWS :NS53z$אNP>$Q\!א3UGNذא،iود رابط http://msdn2.microsoft.com/en-us/library/8bs2ecf4(VS.71).aspx 58 Object Browser اﺳﺘﺨﺪام .11 :א,Tאg(، Object Browser ZI אView Fj.53 hP\אאض!א01،O+\ אVisual Studio hאHא$bא03i!'\ אTool אلlWS لI53 iqV3iWو:3א$+א7Q،gQtא9אhO3و:P3fאن01و، .net UjאhJOوא .:$j!5D אو، Help Fj. U i'د%'\ אz 'אMSDN hP3 z'` אNP> gN3 א5D h3'\ א53 $Q\ . msdn0.'3Ui,3Z9אnDi'د%'\א Name Space ﻣﺠﺎﻻت اﻷﺳﻤﺎء .12 gN3T${tאj אnamespaceאلS System نCª אن01،7وسאH$ لאI53 . AI אname spaces אلGC 59 K^3 hJO א53 $Q$ אg ${ Microsoft I name space ¤NS 03K3a7!bIS Micosoft J!537T\אhJOא0B وMicrosoft.ManagementConsole .ً ^3mono אلKF9g!אWو'!وPQ3h3$I ' g אSystem.Windows.Forms : אname space אلO אنs א'א53 'نP ، ً 79 . Forms zNg%tאjمאg\אnD اﺳﺘﻴﺮاد ﻣﺠﺎﻻت اﻷﺳﻤﺎء .12.1 אKPT'دאصPאo3nDאz9א אدلאNP> C# using System.Data.SqlClient; ﻛﻮد VB Imports System.Data.SqlClient ﻛﻮد :i,3א3אNPF!،NRsאوFz9א\^ل אدلאKnDF.ذא C# SqlConnection sql1=new SqlConnection(); ﻛﻮد VB Dim sql1 as SqlConnection=New SqlConnection() ﻛﻮد i3 K U GZ :'I$ 1M3 אL אlWS O! ، z9 ل אU :OQ 7 _ ' ، K7\ אU :g!:3$+ ﻛﻮد C# System.Data.SqlClient.SqlConnection sql1=new System.Data.SqlClient.SqlConnection(); 60 VB Dim sql1 as System.Data.SqlClient.SqlConnection=New System.Data.SqlClient.SqlConnectionn() ﻛﻮد ildasm اﺳﺘﺨﺪام ﺑﺮﻧﺎﻣﺞ .13 Visual Studio 2008 03 7R\ א23א4 א5Fs 234אאWSNP>، ildasm23GqאU${ F. 23 ] אص9 אnD ع9 א53 CIL אلQ¯H53NP>ًMQא، .net אم$+:F :234א53iH'blWS...234אאWgאص :ND$Q\!א3و234א53+KFNP>و :NS53 رابط http://msdn.microsoft.com/en-us/library/aa730858.aspx ؟open source .net ﻫﻞ ﺗﺒﺤﺚ ﻋﻦ .14 t אprojects אلg,'אS mono project fQ3'S وhttp://www.mono-project.com .O+\'@אNhQ'زnDKF אCIL K .OhVN3nDKFא53 CIL 5P> Portable.NET IوعT3¤NS 61 : NS^وعאTFً1אH${ رابط http://www.dotgnu.org .MONO5D^CVOiH'VfNXPא533د.zא%CU 62 63 اﻟﺒﺎب 5 اﻟﻮاﺟﻬﺔ اﻷﺳﺎﺳﻴﺔ ﻟﻠﻔﻴﺠﻮال ﺳﺘﻮدﻳﻮ 64 65 ﻛﻴﻒ اﻛﺘﺐ اﻟﻜﻮد ؟ .1 FP3%9אlWSنC9، Visual Studio 2008 لI53SאلאpאnDQ$7א%א CnD .net framewrok 3.5 development kit a7!'د% لوI53و:אSRRVא%!،ً3e lWSnD`DnDسH$אאWSUfN، .net 2008 h71Q'1nDًאHد.'نP¦!زg% Visual Studio 2008 لI53g3K3Ntא9א7Q1'لאQ$RK7NאنK.ق1א :aאאאWS53gFNP>ًj$3 رابط http://msdn2.microsoft.com/en-us/library/zcx1eb1e.aspx Visual Studio 2008 Command Prompt اﺳﺘﺨﺪام .1.1 'نP،'1\א3אوאnD عcsc -? 3א: I53NP>، C# 4'م7NNאNsZ!'א אل$Q$RجR،ًQو$Qz,KKF1M5P، C# 'دBZz$א01!3אوאlWS Q3'SوQو$Qz,KKF'م7'i353$OK7\אU، א....hO\وא9 وאout .zאoא53234Q3KUPRSذb! :אKPT:Gcso39CompileKFDNP>،iH'ba] 66 ﻛﻮد csc File.cs :dllo3:Q'RوC ﻛﻮد csc /target:library File.cs :exeo3:Q'RوC ﻛﻮد csc /out:My.exe File.cs :$وא$Ui'د%'3hO3i$CompileKFً אIC ﻛﻮد csc /define:DEBUG /optimize /out:File2.exe *.cs :!'وPQ353aאאאWS53zא$א$Q\!א3NP> رابط http://msdn2.microsoft.com/en-us/library/78f4aasd(VS.80).aspx TextPad اﺳﺘﺨﺪام ال .1.2 + ، z, ] KF *V+ K. وz, אnD KF K. : אnN} ، Jg אiدD9 K. 1 GQوhRObאوq9Qiدאg3א$+אNP>،KQ$وאQ'1:. Notepad אل53iH'13 *jVאKQ$013د3z,....אHאوGZg3א$+אNP>...אn אوHTMLאو .'1\א 67 !sא$،:D vb.net אوC#qoQo3!sא01 אTextPad *אلjVI5Fs53i$وא 53+${ Compile 3!אsאNP>، visual studioUF א'אد5Q''م7Ql$`o\א אa אא0 NP> 'عs'\א אWS 'ل$Q\ \! א، א... C# אلq :3$+\ אRE אل : :N3 ق19وא رابط http://www.eggheadcafe.com/community/aspnet/2/10014016/textpad-and-c.aspx :NS Textpad~אnDgZob'אوא4אhqKhO3${אن01F رابط http://www.textpad.com/add-ons/cliplibs.html 0s'F.'، Reguler Expressions~ אqQ5DhدHنאgO4אqUKQ$אP3 .ً MQ אTextpad אلnDSWOND1!bI4אqY'א. 68 Notepad++ اﺳﺘﺨﺪام .1.3 אلbIK^3 Textpad K!'9}Ht*אjVאQ،K3P:א9،K1 .س'دH'v3:אnN}H$V\אv'O3:אWosא،auto complete :NS$Q\!א3NP> رابط http://notepad-plus.sourceforge.net/uk/about.php : Open Source :אlQ'1Kא303NSl${:O234א رابط http://sourceforge.net/projects/notepad-plus/ SharpDevelop .1.4 :ً MQאFVg%'دوא%'FQ، C# אل3$:%'3 69 :אaאא4D:Dfz$אNP>...hوאدوאg(\אU'Q`'אل'دOX.9'אSو رابط http://www.icsharpcode.net/OpenSource/SD/ Visual Studio 2008 اﻟﺒﺪاﻳﺔ ﻣﻊ .2 $<،:D'N Studio Viusal 'אلS VB.net אوאلC# אلP!'وPQ353$F\ אIDE אل Visual K^3'g!N3q:%'3'نPQW وאExpress3א، 'S وProffessional 'عNא .C# 2008 Express Web Site وCوعT3zTאhאHI${3ولC$`3$+\אqאGو، i3ول234אKqT$ :ً ^3 Project ZI אNew Fj.53،5Q'د%'\אnDKQ$!sא$Q$% 70 $ وאClass nD ً j$3 ' 'دP אP ,, S وConsole Application S א'אعaא OKא3Ukق1N'אع9א..a7!...:ZIאWوعאT\'אאS name space وאلMain . .net 2008 JK3g!: I5301א'אعوaא: Console م$+N،XPא53 ،O+\وعאT\אh'P3YK7NאNP>، Solution Explorer אل${,TאY>nD aqM ل אI 53 i$Q$% h'P3 !s א01 ، !M\ אh'P\ א${ Refernces GQ' . Add aqsوא5>א\وسאH ReferncesnD אل0BضDQr ClassضDHIא01،אضX'אYKQ$אNP>GQ'אאWSKOא : g!*jVقوא1وאDوT3Ui'د%'\אClasses 71 وعT\*אjVI$`Y3:DaqMF.'،وعT\*אjVI${ Properties GQ' .DوT\9*אjVאNP> iH'V FgN h. א$Q$ وClasses hJO אH5P> Class Designer ً MQ א.net אلQ .i,3وعT\אnDFgNaאوא03i,3g71Q53وj3 ﺑﺮﻧﺎﻣﺠﻚ اﻷول .1.2 :'دאPא0s Main lF\ אfunction אلU،Na23אولX`N C# Console.Write("Hello World"); Console.ReadKey(); ﻛﻮد VB Console.Write("Hello World") Console.ReadKey() ﻛﻮد .Visual Studio 2008Uאولh]TC$.אWPS'نP...a7! .234א2X%وF5HزnDaqMאX% 72 73 اﻟﺒﺎب ﻣﻜﻮﻧﺎت اﻟﻠﻐﺔ اﻟﺮﺋﻴﺴﻴﺔ 6 74 75 Console*אلjVInDQ'nDfN،hو$אhq9אh'P\_אDUHr9אK. .NوHدUً79g3$+Ntوא Console ﺧﺼﺎﺋﺺ .1 . ع%Z وאSzD$ دوאل وאKFD و,T אnD P אن א01 ، وسH$ א53 \ אlWS n gDKFt אConsole J9אbNאnDfi V.אHWI]N\אlWS$ND،gDو .ً :Sو،אجI9لوאIد9دوאلאS Console JOאgQ'tوאلא$אSא C# Console.Write(string); // *P . ﻛﻮد Console.WriteLine(string) // zgא$$Q$%1ل79אaqs03*P . string x=Console.ReadLine(); // Zאaqs03izא7א53zg9אQمو$+\א53h I$3izא7 int x=Console.ReadKey(); // Zaqs03izא7אFDzgאQوa7!$وאfizא. ConsoleKeyInfo r= Console.ReadKey(); // QאWً ^3gאHزK^3z,لאIאد5P>،:Iد$izא7א53zg9وאa7!$وאfizא. صI q3U2Nא5Q§ ﻣﻼﺣﻈﺔ . فقط ازل الـ ; من آخر الجملةVB.net لو كنت مبرمج 'نBackgroundColor * وN 'ن אForeGroundColor K^3 א'אنhF bI AIC دوאل :אKPTConsoleColorJOאQ5Dא'نY01،Oא C# Console.ForegroundColor = ConsoleColor.Yellow; ﻛﻮد 76 .iW!Nאg(3$Q$Rg! I وTitle وWindowWidth K^3AIC*jVI¤NS :*אNאD1م7א$QNضאZON،D1א0s'א3$'د Age q\א:F אname – q\א:א :'دאPאQ5DWم7אNNP> C# Console.Write("First Name: " + name + " - Age: " + age); ﻛﻮد :א7Q1،ً MQאKM!אAIC7Q¤NS C# Console.Write("First Name: {0} - Age: {1}" ,name,age); ﻛﻮد KPT exponential K e مو.H d 'ز3Hאم$+*N Format KFDNP>،^א7Q1א1'א :ً ^3א C# Console.WriteLine("E format: {0:E}", 99999); ﻛﻮد ﻣﻼﺣﻈﺔ . فلن تحتاج سوى الزالة الـ ; من آخر الجملةVB.net مجدداً لو كنت مبرمج ﺗﻌﺮﻳﻒ اﻟﻤﺘﻐﻴﺮات .2 :א7Q1h אq\אoQNNP>7وسאH$אUذF C# int x; string name; ﻛﻮد VB Dim x As Integer Dim name As String ﻛﻮد 77 ؟gFg3SF!،h אq\אoQ53 ^U new FP'دא%وª $]NPو،:! Iو U i'د%'\ אsאZ!9 אgH'b S$ 3 'S وnew אم$+ gOQ 5P> 1'אع א9 א 'אعC.W وObم.H9 وאfalse bool 71N\'אعא9אKQ'Q،gאص±TN\א .h אq\א arraylists وobjects אلK^3 new אم$+9g3א$+אNP>9hא53AIא'אعא¤NS5P .:NU:DfN:! Iو : C# U'אع9א7'SאWS ProCSharp 2008 and .net 2008 platform X53iH'Vא 78 .:! I وGetHashCode وEqualsK^39א:.iHوMe Object 537T\'אعא9א0B MinValue وMaxValue K^39*אjVאKFT! long وint K^3F. 'אعא9قא1א3C .h I$\א$Q$R IsLetter وIsDigit K^3*jVInD char 'אلdF!... أﻧﻮاع اﻟﻤﺘﻐﻴﺮات .2.1 $Q$Qو،ً ^3 int , string'عNאGh אq\אoQNNP> Class אلKI دא234א53z%אU .oQא:!'د%'\نאP\א4D'لb'אA$3 لI 9 : 'لb' א$C 01Q 5 q\א אWS ، دאKIא$gOQ q3 ضZON 17N אlWS s' ) א$ج אHI q3 oQ NF. ' 3C ، QHאP 7 KIو دאC ط, KI دא:OQ ' 3@ אO و، א$א .MembernFQLאlWSU،i,3 :'لb'دאא95PF!(i,3ClassJOאKIدא 53:P\ q\ אאTQ:! I وLong وint K^3a'אS'عאولوNא،h אq\א53نD'NQ$ نP3iH,9א:N301نP3 q\ אT! Object of Class وArray K^3G\א3CiאWא .3د.وسHدUKVO'عs'\אאWSnDfN،iאWאU:F. Constant اﻟﺜﻮاﺑﺖ .2.2 5P> ، ^ אو אConstant fQ אW ، ًא$ א:F. q 5P> 9 h א53 ' 'عS Constant ~א :אKPT: C# public const int myNumber = 100; ﻛﻮد VB Public Const myNumber As Integer = 100 ﻛﻮد 79 U T א:3$+ Y3 .H K^3 ، PI=3.14K^3 h9 א\د7 א^'אlWS אم$+ אQ ..אوUl qRنאFM qF:OQ53ً9$^:OQKMOQLאlWSU.א...hLא ...a7!:OQ(LF7אlz1Dوאi$وאi3^ אoQQ Read Only Field اﻟﻘﻴﻢ ﻟﻠﻘﺮاءة ﻓﻘﻂ .2.3 :אKPT:OQQ C# public readonly double PI=3.14; ﻛﻮد VB Public ReadOnly PI As Double = 3.14 ﻛﻮد ط,دونi$وאi3lzTא$F. lz1DאP3אUo:אא$D3،ً3e Constant אلK^3KFQ : ً ^3 אKPToQ(אL@OUF7אlz1Dא C# class MyMathClass { public readonly double PI; public MyMathClass () { PI = 3.14; } ﻛﻮد VB Class MyMathClass Public ReadOnly PI As Double Public Sub New() PI = 3.14 End Sub End Class ﻛﻮد 80 String اﻟﻤﺘﻐﻴﺮات اﻟﻨﺼﻴﺔ .3 String 'عNQ3K'لjאlWSUE$RN String اﻟﺨﺼﺎﺋﺺ واﻟﺪوال اﻻﺳﺎﺳﻴﺔ ﻟﻞ .3.1 אم$+א bوאCא$א *Nد'لא$ Length YVYH7F Compare *Nא5Fsf*אو5DR Contains Y3*אوfrgNQאوC$Q*NאذאنאF!!\ EndsWith StartsWith אوQא$א53z'א،*Nא5FsY3*Qא$אوf'د%نوP3!\ IndexOf QgNא53 LastIndexOf *Nא53Y3z%fW Remove StringאلKIאج*دאHאد Insert *Nא53z%אل$א Replace −)3 DK03*Nא7ً ^3،!'OV3Y3z,G*Nא7 Split i$Q$%!'OV3( small وcapital Yf9אKQ'R ToUpper ToLower 81 : ﺗﻘﺴﻴﻢ اﻟﻨﺼﻮص .3.2 zN*7s'Qא\^لא،!'OV3UbND*NאhQ')7Splitא$אمא$+אNP> ::1وU–h3 DnD C# string[] newarray = g.Split("-"); ﻛﻮد VB Dim newarray As String() = g.Split("-") ﻛﻮد : دﻣﺞ اﻟﻨﺼﻮص.3.3 :אKPT Concatא$אمא$+אو،+אم$+S'صVNא23$a9א7Q1א C# string s3 = String.Concat(s1, s2); ﻛﻮد VB Dim s3 As String = [String].Concat(s1, s2) ﻛﻮد ﻣﻘﺎرﻧﺔ اﻟﻨﺼﻮص .3.4 א$אمא$+אKMO\א53:א9، VB.net U=وC C# U'صVNאH7\==K3\אمא$+א5P> :אKPTEquals C# Console.WriteLine(s1.Equals(s2)); ﻛﻮد 82 VB Console.WriteLine(s1.Equals(s2)) ﻛﻮد – ﺳﻲ ﺷﺎرب ﻓﻘﻂEscape Characters .3.5 Tab KF /t و$Q$%1 /n K^3bאfوL)`'زאًא/f${،אjDhqKU :ً ^3אKPT،l و C# Console.Write("My Name:/nAhmed Gamal"); ﻛﻮد Verbatim fQ 3 אم$+' אS وI K ¤NS ، // GP אن$ ! / GP אنhدHא ذא אW KPT Escape Characters אل53 7ون א$ دD * L אlWS U NP> Strings :ً ^3א C# Console.WriteLine(@"C:\MyApp\bin\Debug"); String اﻟﺘﺤﻮﻳﻞ ﻣﻦ وإﻟﻰ ﻛﻮد .3.6 :ً ^3אKPT،l&N3*N'لאt وאParse א$אnD9'אعא9(א3' C# int x = int.Parse("1"); bool v = bool.Parse("True"); ﻛﻮد VB Dim x As Integer = Integer.Parse("1") Dim v As Boolean = Boolean.Parse("True") ﻛﻮد 83 ً ^3אKPT*gQ'R ToString א$אnDًMQ'אF C# string x = m.ToString(); ﻛﻮد VB Dim x As String = m.ToString() ﻛﻮد StringBuillder .3.7 KPT VB.net U & K3\وאC C# U+K3\אمא$+9N3^ ونP`]אQ،'صVNא23$'م73$ND :وZPא$Q4אدא$3!אs^لא3−א C# // C#: Label1.Text = Text1.Text + "@hotmail.com"; ﻛﻮد VB 'VB.net: Label1.Text = Text1.Text + "@hotmail.com" ﻛﻮد لU ، StringBuilderJOאم א$+ 'صVN א23$ AIC 7Q N 3$. Visual Studio نC 9 :אKPT'صVNא23$g3א$+א5P>، System.Text.StringBuilder zא C# //C#: System.Text.StringBuilder mail = New System.Text.StringBuilder(Text1.Text); mail.Append("@hotmail.com"); ﻛﻮد VB 'VB.net: Dim mail As New System.Text.StringBuilder(Text1.Text) mail.Append("@hotmail.com") ﻛﻮد 84 & وC+h 3\אمא$+א3א،lzT(אLWN3'SFK(Q stringbuilder אنU5FPQYN9אYقHOא .23دFDK03 String אل53$Q$% Object KF'م7Q'g! .Net Gotachas X53i,3H7\אH'VNو،'صVNא53د$D23$'م7 Loop ^ل3ضZONوאن م. و، 23 دFD 1000000 n و23 دhFD 10 53 zא$ א23 دhFD د$ HI אKF م. ، ^WONא53ذز03،Q$7א23$אh 33אم$+ אوאStringBuilder אم$+אYzאدאH7} .gN3KP ...ً Q77.د59.4c3562.933אنnN9 'ص؟؟؟VNא23$+م & אو$+ز3KS...وאن hFD وRemovefW وInsert אجH وאدReplace אل$ אhFD ً MQ אstringbuilder JO'! א aאאאWS لI53'مא3'D$3H7Fi ^:%وCnD ع9אNP>،i ^AIC'صV : Code Project 53 رابط http://www.codeproject.com/KB/cs/StringBuilder_vs_String.aspx 85 اﻟﺘﻌﺎﻣﻞ ﻣﻊ اﻟﺘﺎرﻳﺦ واﻟﻮﻗﺖ .4 :Y3¢QH!s9ً ^F!، DateTime P\אU.'وא¢QHQ30B${ C# DateTime dt = new DateTime(2004, 10, 17); ﻛﻮد VB Dim dt as DateTime = New DateTime(2004, 10, 17) ﻛﻮد :Lא¢QHאD1 C# Console.WriteLine(DateTime.Now); ﻛﻮد VB Console.WriteLine(DateTime.Now) ﻛﻮد TimeSpan אم$+ًMQC.'א03K3א5P> C# TimeSpan ts = new TimeSpan(4, 30, 0); ﻛﻮد VB Dim ts as TimeSpan = New TimeSpan(4, 30, 0) ﻛﻮد :אKPT Substract وAdd אول$אمא$+v1!وאs9א C# Console.WriteLine(ts.Subtract(new TimeSpan(0, 15, 0))); ﻛﻮد VB 01.Console.WriteLine(ts.Subtract(New TimeSpan(0, 15, 0))) ﻛﻮد وC 86 C# dt = dt.AddMonths(2); ﻛﻮد VB dt = dt.AddMonths(2) ﻛﻮد :اﻟﺘﺤﻮﻳﻞ ﺑﻴﻦ اﻟﻤﺘﻐﻴﺮات اﻟﻤﺨﺘﻠﻔﺔ .5 :YjHYD'h אq\אYh Q'Rא7N،Qא$ Widening Conversions • Narrowing Conversions • Widening Conversions .5.1 nFو،hא53א'عiHIg!5P>9tאh Q'Rאh Q'Rא53'عNאאWg$V7Q :א\^لאU Integer Short53KQ'R^لذא3،upward cast C# Short x=5; power(x); ﻛﻮد VB Dim x As Short = 5 power(x) ﻛﻮد power א$אUو C# int power(int number) { return number^2; } ﻛﻮد 87 VB Private Function power(ByVal number As Integer) As Integer Return number Xor 2 End Function ﻛﻮد LאlWSU، Short 'ع53hkNHאF! Int 'ع53hK7א$אنא$`(9' 07Q Short KA$3و!¦نא، Short אلA$3534 אInteger אلA$3نPT3¤NS'نP5 .$]KP Integerאل5Fs Narrowing Conversions .5.2 Short 'ع532N وאInteger 'ع53 אنq\^ ً'نא3،qbא49א53KQ'Rא،PאLא '5Pو، Short KnV.א$Lא53qb אInteger YF.'عאF'نRRbiH'V39אKF، .PT32N !¦نذShort אلA$3ود${وزgD'FאنNsZ!א :]א1אH1Q'دوPאאWSK^353i,3Q3'PאN>،GאאWk Cannot implicitly convert type 'int' to 'short'. ]`LאlWSU،hعאsذ5D2'n17NאlWS5DًFHKQ'RאUNH'5P Cast ~nFQ\ Cast ﻋﻤﻠﻴﺎت ال .5.3 ،KQ'RאhFDKUg3א$+ א5P>K،a7!qb4א53KQ'RאnD cast אلhFD1N9 :אKPT Short IntegerKQ'R'Skאم$+אaא C# int var=10; short var2 = (short)var; ﻛﻮد 88 VB Dim var As Integer = 10 Dim var2 As Short = CShort(var) ﻛﻮد :א\^لאNsZ!ذא'א35P،10gא$`N var2 `D1NF.'،א\^لאU C# int var=100000; short var2 = (short)var; Console.WriteLine(var2); Console.ReadKey(); ﻛﻮد VB Dim var As Integer = 100000 Dim var2 As Short = CShort(var) Console.WriteLine(var2) Console.ReadKey() ﻛﻮد ، 31072−S`N'نאP234F73iH'V5Pو،KFNg.'5P>5`Nא אو، א. א5D iدQ زK 03 .H ص7 א53 و32768 53 zא$ אhאH,9@ אP Q3'P'م א7 .32767 'S'ع وN nV.9 אA$\ אو אnV.9 א$L א53 2N א. אv1 'م7Q 'g! HVI KVOgDfNtوאTry Catsh אم$+ًאFjدאKMO\א53:¦!،h Q'Rא53'عNאאWSאم$+ .XPא53دم.z%U Convert اﻟﺘﺤﻮﻳﻞ ﺑﺎﺳﺘﺨﺪام .5.4 :ً ^3אKPT Convert JOאمא$+hא53אא'אعYKQ'Rא5P> C# myByte = Convert.ToByte(myInt); ﻛﻮد VB myByte = Convert.ToByte(myInt) ﻛﻮد 89 .6 أﺳﺎﺳﻴﺎت اﻟﺸﺮوط.6.1 .net اﻟﺠﻤﻞ اﻟﺸﺮﻃﻴﺔ ﻓﻲ :אKPTg7Qو، if else م$+tאSTאKFאaא C# if (x==5) Console.WriteLine("five"); else Console.WriteLine("notFive"); ﻛﻮد VB If x = 5 Then Console.WriteLine("five") Else Console.WriteLine("notFive") End If ﻛﻮد אم$+ط,53^א23د5P>،TאKFאU > ==و!=و < وhH7\אم!א'אع א$+אQ :אKPTelse if C# if (x > 90) { Console.WriteLine(";)"ز ﻛﻮد } else if (x >=50) { Console.WriteLine("%"); } else { Console.WriteLine("GאH"); } 90 VB If x > 90 Then Console.WriteLine(")"ز ﻛﻮد ElseIf x >= 50 Then Console.WriteLine("%") Else Console.WriteLine("GאH") End If אhqQ$7(مאNא.^طאTאWONQ9( وTrue) 2N'ن אUאوFא1Q :אFאK^3ًMQא1'وRRbgM7 tوא ﻣﻼﺣﻈﺔ :אKPTNو,P'م7نCCאل0tאhqאh jD03'د$.N C# if (string.lenght) ﻛﻮد ...$XH, א03ًLb$Q_(مNאאWSTrue=طTא7dنCF.:'ن5P> دﻣﺞ اﻟﺸﺮوط .6.2 g' U طT אWON Q r وطT אY 23$ And وC && אم$+ א5P> ط, 53 ^ אKF 'نU`1!||אKPTXH,U:QW وאOr K33אم$+ אوאTrue ً B G@N9 (O)م$DUc!!אKPTGPQW وאNot K3\א،ًRRbgN3 $אوא :ً ^3אKPTوطTאKIא$9nh9LאlWSU'אس.9א C# if ((x < 90 || x>50) && (!name="ahmed")); ﻛﻮد VB If (x < 90 Or x > 50) And (Not name = "ahmed") Then End If ﻛﻮد 91 AndAlso .3.6 :א2Nولא$%k'نPQو،YTאHIאQאنAndK3\אUوnet.hU'دN 2Nא 2KI$3 1KI$3 True False False False True True False False True False True False DدאC$%'Q9و،JI'نPi,3F !¦نאfalseאولf1'نאU:]ªRوא .AndK3\א:OQ93אWSo 5Pو،طTא53^אzא537R .±I 'دא%وUi,3False$Q'g!،o'عs'\!AndAlso035P :'دאPضאZON،i$Q$,ذ؟53$Oذא3 C# if (id > 0 & SearchForID(id)>0) { // do something } ﻛﻮد VB If id > 0 And SearchForID(id)>0 Then ' do something End If ﻛﻮد \אUًא$%$Q$,za2NQ3'SوRא3אWON!،OVא53qbאId'نאلnو0.א'אU :אKPTQ$7א7Q1gDGqאQ،:ج9 C# if (id > 0) { if (SearchForID(id) > 0) { // do something } } ﻛﻮد 92 VB If id > 0 If SearchForID(id)>0 Then ' do something End If End If ﻛﻮد :AndAlso7Q1و C# if (id > 0 && SearchForID(id) > 0) { //do something ﻛﻮد } VB If id > 0 AndAlso SearchForID(id)>0 Then 'do something End If ﻛﻮد OrAlso .6.4 :א2jNولא$%:WوאORK3\א033אHPQ،And03لL'אSF 2Nא 2KI$3 1KI$3 True True True False True True False False True False True False DدאC$%'Q9و،RRb'نPi,3F!¦نאTrueאولf1'نאU:¦ªRوא .OrK3\א:OQ93אWSo 5Pو،طTא53^אzא537R سH$אUلL'אSFh I$3i$D537RאzNDOPQ9W وאOrAlsoK3\אنאWSK%א53 .AndAlso03ًMQאא 93 Switch Case اﺳﺘﺨﺪام ال .6.5 :אKPT Switch Case אم$+אSTאKF`AIא7Q C# switch (x) { case 90: Console.WriteLine(";)"ز ﻛﻮد break; case 50: Console.WriteLine("%"); break; } VB Select Case x Case 90 Console.WriteLine(" )"ز ﻛﻮد Case 50 Console.WriteLine("%") End Select وطT א. HI אUHאF9 א53Q3'P א0N> אن ذG א، طTאI אU break !s@ אN 9 oM !gN3א703 nوطTאKnDlHو3UGNذא3א،ط,אولnD^Q3$ND .M\אlWkض5`'אلOאU،break 94 :اﻟﺤﻠﻘﺎت اﻟﺘﻜﺮارﻳﺔ .7 :`DnDسH$אאWSUHאPق אvTN،hא3i$D3אوא1HאPQHאPאh7Lمא$+ For - Next Loop .7.1 :'دאPאgD^ل3aא،g!i'1אHא$73وQgNوאQא$א17$Q$ QHאP7 C# for (int i = 0; i < 10; i++) { Console.WriteLine(i); } ﻛﻮد VB For i As Integer = 0 To 9 ﻛﻮد Console.WriteLine(i) Next - :ً ^3%مאو.H9אD1 - אKPTً ^32=O7אHא$73KFD5P> C# for (int i = 0; i < 10; i+=2) { Console.WriteLine(i); } ﻛﻮد VB For i As Integer = 0 To 9 Step 2 Console.WriteLine(i) Next ﻛﻮد 95 While Loop .7.2 :10.Hאد$'لאbوnً ^3ضZON،Y3 ط,7nKFאUFHאP7 C# int x = 0; while (x < 10) { Console.WriteLine(x); X++; } ﻛﻮد VB Dim x As Integer = 0 While x < 10 ﻛﻮد Console.WriteLine(x) X+=1 End While 0MوQא$אU Do oMf'L אlWSU، exit لI אدnhلIאد،F.H AIא .QgNאUWhile C# string inp; do { inp = Console.ReadLine(); Console.WriteLine(inp); } while(inp!="exit"); ﻛﻮد VB Dim inp As String Do inp = Console.ReadLine() Console.WriteLine(inp) Loop While inp <> "exit" ﻛﻮد 96 For Each Loop .7.3 :ً ^3N3!'OV3bNDKnDאنHو$ً ^3 ،Y3z,(K)nDאنHو$ C# int[] arr = { 10, 20, 30, 40 }; foreach (int i in arr) Console.WriteLine(i); ﻛﻮد VB Dim arr As Integer() = {10, 20, 30, 40} For Each i As Integer In arr Console.WriteLine(i) ﻛﻮد Next 97 اﻟﺒﺎب 7 ﻣﻜﻮﻧﺎت اﻟﻠﻐﺔ اﻻﺳﺎﺳﻴﺔ – اﻟﺠﺰء اﻟﺜﺎﻧﻲ 98 99 ﻟﻨﻔﻬﻢ ﺑﺮﻧﺎﻣﺠﻨﺎ اﻷول .1 :אKPTنW وאHello World B D1אولNN(9' C# using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication4 { class Program { static void Main(string[] args) { Console.Write("Hello World"); Console.ReadKey(); } } } ﻛﻮد :אKPTنP!!`'אلU3C VB Module Module1 Sub Main() Console.Write("Hello World") Console.ReadKey() End Sub End Module ﻛﻮد . using אم$+א'אدPg3$+N tאhP\'א אدאSC#Ul$`N3אول Class J! 'S Module אل، i,3 :I א'אد دאP F. Module oQ ! `'אلO אU 3C 'ع53DوT3'نU'Q`'אل'دOאS]TNQ Shared-StaticSgJ!0BنCא$D3QدD .VB K : 0s' W א9' אS وN4 אصname space אلoQ 'S C# 'دU ^ אzא Nj4¨د3אUNFF ... MainNQ$9 אClass אل53و،234אh'P3 100 Main nF\ אClass אلUjאא$א، Classes אل53^אوא$وא53'نPQ23 C!¦ن:%'א .234אUz,אولSWONQt وאmain א$אS !'OV3:qT03K7Q234אאنאWSnN3، args א3א53D'F Main א$אK7 Command nFQ3'Sو،k I53234א$Q3KلHא5P> ، args[n] args[0] 53 .Line Parameters SQe5P>tאh אq\א53D'FS Command Line Args אل،vTאUH35D$9P :א39אPNF.'ً ^3،ط7NאUPR :qT.و234 ﻛﻮد Explorer http://www.vb4arab.com KPT:RO'م7QZא0.'3ذא ن،:HF\* אNאizא7'م7Q، Expolorer 23!Q3אول U234@אOgא03hא$¡אOV3O'م7! C:/ً ^3 H3'ن3א،Z9אOV\'دg\א .QgNא : For Loop Q5D:iF\אh אq\ אizא. لI53nD{ذ01 C# ﻛﻮد for (int i = 0; i < args.Length; i++) Console.WriteLine(args[i]); VB For i As Integer = 0 To args.Length - 1 Console.WriteLine(args(i)) Next ﻛﻮد UGtאhאZ3Hא53!و353 وH3P.، Run XSW.אن : RunUא39ز אg%U،SQe ﻛﻮد C:\Users\Ahmed\Documents\Visual Studio 2008\Projects\ConsoleApplication4\ConsoleApplication4\bin\Debug\consoleapplication4. exe ahmed ali 101 :אKPTنg&Wא2Nא א$DF!و،قHز9 مPאOI5Q'Qً ^3 0'د%وU אولوq\אizא7'م7N،0Q1 :W'دאصP'אSאWS،" مPאOI5Q' Qذ C# if (args[0] == "0") { Console.BackgroundColor = ConsoleColor.Blue; Console.WriteLine("0 enterd"); } else { Console.BackgroundColor = ConsoleColor.Red; Console.WriteLine("Empty"); } Console.ReadKey(); ﻛﻮد VB If args(0) = "0" Then Console.BackgroundColor = ConsoleColor.Blue ﻛﻮد Console.WriteLine("0 enterd") Else Console.BackgroundColor = ConsoleColor.Red Console.WriteLine("Empty") End If Console.ReadKey() 53 $] %r 5 ذن، ]1I H g( .. h אq3 אQF 7 _ ' ذא3 ، PT3 NS Ng%'א 53$] !א¤NSذאن،h אq3'د%و53$]אQ5DW'م7N،gzא.K. س3H 'د%و :^`]'نאYTא53אKIذאא،Obg' 102 C# if (args.Length > 0) { if (args[0] == "0") { Console.BackgroundColor = ConsoleColor.Blue; Console.WriteLine("0 enterd"); } } else { Console.BackgroundColor = ConsoleColor.Red; Console.WriteLine("Empty"); } Console.ReadKey(); ﻛﻮد VB If args.Length > 0 Then ﻛﻮد If args(0) = "0" Then Console.BackgroundColor = ConsoleColor.Blue Console.WriteLine("0 enterd") End If Else Console.BackgroundColor = ConsoleColor.Red Console.WriteLine("Empty") End If Console.ReadKey() אKPT$وא1U$]אK< אنNذא'א3،IK¤NS C# if (args.Length >0 && args[0] == "0") ﻛﻮد VB If args.Length > 0 AndAlso args(0) = "0" Then ﻛﻮد 103 i,3ج:¦!S$®_طא^ وذאTK7NS$%ذאو،سZ3H'د%و53$] :אcQאWS ...^طאTאizא.دون W אAndAlsoאم$+9 1MK، VB.net U:715P>5 And K3\אنאWQ$א .7وسHدU:, Function اﻟﺪوال .2 'S:ج3K،h אq\א53د$D]وאل$א53د$DאzTאNNP>، Main دאU$S,F FدאFVN^ ًא3 ضZON،gN3جHא2NًאMQوא،א$KVאنk $Qtאh א3H! א3 :אKPTא$'ن אP، int 2 و§جint YF.HK7،0Fא C# static int sum(int number1, int number2) { int total = number1 + number2; return total; } ﻛﻮد ﻛﻮد VB Private Function sum(ByVal number1 As Integer, ByVal number2 As Integer) As Integer Dim total As Integer = number1 + number2 Return total End Function :ً ^3אKPT gjD$ אMain لI53ولRN،53و C# int result = sum(5, 8); Console.Write(result); Console.ReadKey(); ﻛﻮد VB Dim result As Integer = sum(5, 8) Console.Write(result) Console.ReadKey() ﻛﻮد 104 ؟؟XH,אU Static gאnD sum oQ\ذא static 'ع53S Main و}אندא، static لدאI53 Static دאzD$א5P>9:אGא nDfN،ًMQ אstatic S main لאلI53gjD$ אQAI'نאدאאPאن53$ ! .ً79 !s9אKbOא mehtods اﻟﻄﺮق .3 :אKPTHضD دאK^3،2$9tאא$אSق1א C# void printmsg(string msg) { Console.WriteLine(msg); } ﻛﻮد אKPT 'نP VB.net 03ًMQאF\'אSو، Sub 7Q1אoQQن،6 `'אلOאU VB Private Sub printmsg(ByVal msg As String) Console.WriteLine(msg) End Sub ﻛﻮد Out اﻟﻮﻇﻴﻔﺔ .4 دא53`iدDدאHذא'א3، return لI53`Nعא%H'م7N¦! א\^لאUNFF :אKPT Out א$אمא$+ذQ،void C# static void sum(int number1, int number2, out int total) { total = number1 + number2; } ﻛﻮد 105 ﻛﻮد VB Private Shared Sub sum(ByVal number1 As Integer, ByVal number2 As Integer, ByRef total As Integer) total = number1 + number2 End Sub iH'V 3 KF P 5P و، C# 'د אلP RRV אBZ אS `'אلO b א7א א$א Ydn 'دPאאWS53zא$אgNDzNq9'م7NאW، Shared5DcqنC$9 MoudleURRb .g$j!وSN3v,$D'3 :ً MQ`אNضא: جW אq\אQeQא$אzD$א$NDو C# int result; sum(5, 8,out result); Console.Write(result); Console.ReadKey(); ﻛﻮد VB Dim result As Integer sum(5, 8, result) Console.Write(result) Console.ReadKey() ﻛﻮد ؟return אم$+א53ً9$ 7Q1אlWSאم$+9c!$Q$.WאG'אS35Pو K 33!@א،F7وא0FوאXMא2K^3`53^אiدDאhدH'אcאS، a9א%9א . out אم$+'Sa9אKLא،¤NSgzא.مو.H9!'OV3iدDאA' 106 byval واﻻرﺳﺎل ﺑﺎﻟﻘﻴﻤﺔbyref اﻻرﺳﺎل ﺑﺎﻟﻤﺮﺟﻊ .5 :אKPTv1אFضא\^لאصZON C# int x=5; int y=10; sub(x,y); ﻛﻮد VB Dim x As Integer = 5 Dim y As Integer = 10 sub(x, y) ﻛﻮد א$وא C# ﻛﻮد static void sub(int number1, int number2) { number1 = number1 - number2; return number1; } VB Private Sub [sub](ByVal number1 As Integer, ByVal number2 As Integer) number1 = number1 - number2 Return number1 End Sub ﻛﻮد ، S%א،SNHאt אx F.53אWS qKS5Pو، number1F. q NF.7אא$אU . X F.א و$ אx F.لHLאlWSU'م7F7لאHfQ3אWS ،א$אiאWאU X q\'אنאNDلHאQLאlWSU،^ אLאS ByRef 0%\لH9א . x q\אnDiHوMp number1U qאنאcQ 3אWS :'دאPאGP ByRef 7Q1'دאPאP 107 C# static void sub(ref int number1, ref int number2) { int result = number1 - number2; return result; } ﻛﻮد VB Private Sub [sub](ByRef number1 As Integer, ByRef number2 As Integer) Dim result As Integer = number1 - number2 Return result End Sub ﻛﻮد :3K3 !אClass K^3\ אh אq\א3א،1אh אq\א03a7!:715P>F7لH9א ...ً sאZ!אByRef Arrays اﻟﻤﺼﻔﻮﻓﺎت .6 Arrays ﻣﺎ ﻫﻲ اﻟﻤﺼﻔﻮﻓﺎت .6.1 GPbND 5 k' م.H9 א53 Array oQ ، 'عN@ אO 53 h א53 5D iHD S !'OV\א :'دאPא C# int [] intarray = new int[5]; ﻛﻮد VB Dim intarray As Integer() = New Integer(4) ﻛﻮد : אK^3'دGP!'OV\אbND$אizא7،4nوOVא53h!'OV\אU.Z אC$Q C# Console.WriteLine(intarray[3]); ﻛﻮد 108 VB Console.WriteLine(intarray(3)) ﻛﻮد :אKPTHאPאh7אم$+א5P> bNא0Bizא7و C# for (int i=0;i<5;i++) Console.WriteLine(intarray[i]); ﻛﻮد VB For i As Integer = 0 To 4 Console.WriteLine(intarray(i)) Next ﻛﻮد :ﺗﻜﻮﻳﻦ اﻟﻤﺼﻔﻮﻓﺎت .6.2 :ً ^3אKPT!'OV\ אhلאIد9Kg9א7Q1א C# array[0]=15; array[1]=20; array[2]=13; ﻛﻮد VB array(0) = 15 array(1) = 20 array(2) = 13 ﻛﻮد :ً ^3אKPT!'OV\אhلאIد9AIC7Q¤NS אن9،ًMQאHאP7Q5DوC C# int[] intarray = new int[] { 15, 20, 13 }; ﻛﻮد VB Dim intarray As Integer() = New Integer() {15, 20, 13} ﻛﻮد 109 اﻟﻤﺼﻔﻮﻓﺎت ﻣﺘﻌﺪدة اﻻﺑﻌﺎد .6.3 h!'OV\א53AIא'אعא¤NS، one dimensional $אQ אدh!'OV3S7אh!'OV\א0B : Matrix - nF−د9אjN!'OV3nD^ل3אWS، Multi dimensional د9 אiد$3אوjN C# int matrix = new int[3,3]; ﻛﻮد VB Dim matrix As Integer = New Integer(2, 2) ﻛﻮد :(sאZ!א)אKPT!'OV\אKP,'نP 000 000 0 0 0 :אKPT!'OV\א53 17hلאIאد5P>و C# matrix[1,2]=20; ﻛﻮد VB matrix(1, 2) = 20 ﻛﻮد :ً ^3 אKPTم$+\אQ5D5Pو،hلאIد9HאP7KFD5P> C# int matrix = new int[3, 3]; for(int i=0;i<3;i++) for(int j=0;j<3;j++) matrix[i,j]=Console.ReadLine(); ﻛﻮد 110 VB Dim matrix As Integer = New Integer(2, 2) {} For i As Integer = 0 To 2 For j As Integer = 0 To 2 matrix(i, j) = Console.ReadLine() Next Next ﻛﻮد .ً MQאKPT@אOND1وא ﻋﻤﻞ ﻣﺼﻔﻮﻓﺔ ﻣﻦ اﻟﻤﺼﻔﻮﻓﺎت :אKPT!'OV3 nDgN3VNDK'd!'OV3KFD5P> C# int[][] complexarray = new int[5][]; ﻛﻮد VB Dim complexarray As Integer()() = New Integer(4)() ﻛﻮد :ً ^3'دאPאQ5Dg!VND'لb'א5P>و C# Console.WriteLine(complexarray[1][4]); ﻛﻮد VB Console.WriteLine(complexarray(1)(4)) ﻛﻮد . complexarray!'OV\א5Fsi'د%'\'!אوאOV\א534.HVN אcQ3אWSو 111 ارﺳﺎل واﺳﺘﻘﺒﺎل اﻟﻤﺼﻔﻮﻓﺎت ﻣﻦ وإﻟﻰ اﻟﺪوال .6.5 :אKPT!'OV3hQ')D1دאKFDNP> C# static void print(int[] arr) { for (int i = 0; i < arr.Length; i++) Console.WriteLine(arr[i]); } ﻛﻮد VB Private Sub print(ByVal arr As Integer()) For i As Integer = 0 To arr.Length - 1 Console.WriteLine(arr(i)) Next End Sub ﻛﻮد .'!אOV\אnDpא$אUKQ$CאW،ًsאZ! אbyref g3K3אQ:ًאnN9 :אKPT'دPאGP، return א$ א53:دD'دא3S array 'نאلU C# static int [] read() { int []arr=new int[3]; for (int i=0;i<3;i++) arr[i]=Console.Read(); return arr; } ﻛﻮد VB Private Function read() As Integer() Dim arr As Integer() = New Integer(2) {} For i As Integer = 0 To 2 arr(i) = Console.Read() Next Return arr End Function ﻛﻮد 112 ﺧﺼﺎﺋﺺ اﻟﻤﺼﻔﻮﻓﺎت اﻟﺮﺋﻴﺴﻴﺔ .6.6 :ً3א$+אS^وאSg,א،gDKFאU¤$D $.*ودوאلjVInDh!'OV\'א אم$+9א bא !'OV\אbNDد 'ل$ Length !'OV\אbNDGZ'م7 Sort !'OV\אbNDG@P'م7 Reverse V q3!'OV\אKQ'R ToString !'OV\אUد9دא$Dد$ Rank Enumeration اﻟـ .7 234אKIدאO. وh9K^ebNא53D'FnD' enumerations - ~HVIאEnum hאH א53א'אعE NQ$ضZON،hאHאh Q\'دUg3א$+'אS Enum אلnD^ل3aא N¦!،ً ^3hאi$D.U2 و1،0.KP,nDgNQ+'م7N'، FIAT ًאIوאNissan ،Toyota ، ً 79 :B W وאgل אI אد:NP> K ، iH K .H لI אدnD 234\א4< אن$Q 9 .:&N\א.א C# enum cars { toyota=0, nissan=1, fiat=2 } ﻛﻮد VB Enum cars toyota = 0 ﻛﻮد 113 nissan = 1 fiat = 2 End Enum 'عN א$Q$5P>،ًMQא\אHVI9 enum אلVNDg!5Q§Qt א\א$Q$ًMQאNNP> :אKPTذnD^لFbyte C# enum cars:byte { toyota=0, nissan=1, fiat=2 } ﻛﻮد VB Enum cars As Byte toyota = 0 nissan = 1 fiat = 2 End Enum ﻛﻮد ، אم$+9' אg N KOPQ } 'ز3و אC م.H9 א53 ً9$ 4 אU i$Q$ אz9אم א$+ אNNP> אن .iHאאnDzNiHدאضא$QN^ ً א3ضZON C# static void printPrice(cars mycar) { if (mycar == cars.fiat) Console.WriteLine("20,000"); else if (mycar==cars.nissan) Console.WriteLine("30,000"); else Console.WriteLine("40,000"); } ﻛﻮد VB Private Sub printPrice(ByVal mycar As cars) If mycar = cars.fiat Then ﻛﻮد 114 Console.WriteLine("20,000") ElseIf mycar = cars.nissan Then Console.WriteLine("30,000") Else Console.WriteLine("40,000") End If End Sub . byte 'ع53S+\אOא7אن אHRsوאzمא$+Nא$<אWPS K^3h Kא0.א'אU،وز$NQ'b אAPI دوאلS enum Ki$jO:§NP> 3sאو ً9$3 q\9$ Local K^3Rsא'אzאKO${0.א'אU5P،وאل$ A127X 00 . 'ز3אBZ'س3. 'د%دونوgFg!DGVtوאi$7\'زא3א53 Structure اﻟﺘﺮاﻛﻴﺐ .8 nD *jVI אK" 01 SzT אNP> h א53 VV א'אعS Structs אوStructure ~א 0NVאKQ'د3$<iHKP،iH^لא3'S Struct nD^ل3aא،:! Iدوאلوnאوh אq3KP, :ً ^3אKPT Struct אلNNP>،ً ^3 'א.HوH\وאא C# struct Car { public int carNumber; public int year; public string factory; }; ﻛﻮد VB Structure Car Public carNumber As Integer Public year As Integer Public factory As String End Structure ﻛﻮد 115 :אKPTgVjVIY'م7N¦!iH53+oQ$Q3$NDوאن C# Car ahmedcar = new Car(); ahmedcar.carNumber = 1000; ahmedcar.factory = "Nissan"; ahmedcar.year = 2007; ﻛﻮد VB Dim ahmedcar As New Car() ahmedcar.carNumber = 1000 ahmedcar.factory = "Nissan" ahmedcar.year = 2007 ﻛﻮد nD'd אVI StructNsZ!'א، Struct lHو$I'אS VNDnD Struct 'אلdאن5P> :אKPT'نذP!،ً ^3VIאzg97\אh'אNم وא$+\אא C# struct Licence { public string UserName; public int yearsToFinish; } ﻛﻮد VB Structure Licence Public UserName As String Public yearsToFinish As Integer End Structure ﻛﻮد :אKPT!ذ،iH*אjVI53 z% אVIHK<دאنHوאن'א C# struct Car { public int carNumber; public int year; public string factory; public Licence carLicence; }; ﻛﻮد 116 VB Structure Car Public carNumber As Integer Public year As Integer Public factory As String Public carLicence As Licence End Structure ﻛﻮد :אKPT 'دGPNiH*אjVI$Q$Rو C# Car ahmedcar = new Car(); ahmedcar.carNumber = 1000; ahmedcar.factory = "Nissan"; ahmedcar.year = 2007; ahmedcar.carLicence.UserName = "Ahmed Gamal"; ahmedcar.carLicence.yearsToFinish = 3; ﻛﻮد VB Dim ahmedcar As New Car() ahmedcar.carNumber = 1000 ahmedcar.factory = "Nissan" ahmedcar.year = 2007 ahmedcar.carLicence.UserName = "Ahmed Gamal" ahmedcar.carLicence.yearsToFinish = 3 Struct اﻧﺸﺎء اﻟﺪوال داﺧﻞ ال ﻛﻮد .6.1 'ذnD^ل3 aא، Struct אאلWSnDhF'مא7 دאzT אStruct אKIدאUNNP> :אKPT Struct אلLאlWSU5P>، אVIH$Q$` renew دאKFDدHא C# struct Licence { public string UserName; public int yearsToFinish; public void renew(int periode) ﻛﻮد 117 { yearsToFinish += periode; } } VB Structure Licence Public UserName As String Public yearsToFinish As Integer Public Sub renew(ByVal periode As Integer) yearsToFinish += periode End Sub End Structure ﻛﻮد .i,3א$אlWS'لb'אQ 5DVIאiZ!$Q${NNP>אWPSو لIאد0N\ دאوذQ5D9i,3bN'لאb'FQ9iאدUO אh71אU Q Struct אل53 + zT א$^ ً و3 Struct אلzT9 Create دאKFD 5P> . ً ^3 'q3 h .h אq\א.Q¯ FQ5hא±\א$אlWSzD$א Qe Struct אل53 + zT א. وNP> ، $T\ אو אConstructor אم$+ I K ¤NS :אKPT$T\אQ،'1\ אhא C# struct Car { private int carNumber; private int year; private string factory; private Licence carLicence; public Car(int p_carNumber, int p_year, string p_factory,Licence p_carLicence) { carNumber = p_carNumber; factory = p_factory; year = p_year; carLicence = p_carLicence; } }; ﻛﻮد 118 ﻛﻮد VB Structure Car Private carNumber As Integer Private year As Integer Private factory As String Private carLicence As Licence Public Sub New(ByVal p_carNumber As Integer, ByVal p_year As Integer, ByVal p_factory As String, ByVal p_carLicence As Licence) carNumber = p_carNumber factory = p_factory year = p_year carLicence = p_carLicence End Sub End Structure h!3، Struct جאلHI:'لb'א5P>9r private 'نP h אq\'لאb'אN'Nאª9 public אنאنOPQ5PوK`9אW OOP _אلDUKI$FNNs'א3 $'نאP'لb'א אلKIدא539 k'لb'א5P> ! private 3א،א$ אوאq\نאP3א53'لb'א. K{ .Struct Reference واﻷﻧﻮاعValue اﻷﻧﻮع .9 nN3، Value Type 537T3h(א'אع א3אن$`N،h אq\سא'אعאHدAICi3$D' :אKPTً9^3NsZ!!'א،:OK^>gN3 q3 K אنValue Type 537T3א'אعlWSאن C# int x=5; int y=x; y=18; Console.WriteLine(x); Console.WriteLine(y); ﻛﻮد VB Dim x As Integer = 5 Dim y As Integer = x y = 18 Console.WriteLine(x) Console.WriteLine(y) ﻛﻮد 119 g! y=x BUNאGא،Qא$ אUgNNQوNא،:bIF.: y وx 53ً אن$`N . x F.nDKVd y q3]TNQאنQ3'Pא ...ً MQ אstruct אلnD ،9אh אq\אnD1NQ(مNאאWS@O אKPTiH^لא3ضZON،א\^لgD1NQ9 Class אلK^3 Refernce Types 'ع53א'אع C# class car { int carNumber; string carName; } ﻛﻮد VB Class car Private carNumber As Integer ﻛﻮد Private carName As String End Class :אKPT'نא\^لP، ints אل03 @א\^لאOGPNوאن C# Car x = new Car(); ﻛﻮد x.carNumber=1; Car y=x; Console.WriteLine (x==y); VB Dim x As New Car() x.carNumber = 1 Dim y As Car = x Console.WriteLine(x = y) ﻛﻮد 120 y وx q\ذאنא، ]1]! gDKQ$אNP> car 53+nD'd y q\אنא5(N' 53ذ53$]אNP>،I³KQ$UGFS$ אUKQ$]!و، q\@אON ونTQ :אK^3 ل'دI C# Car x = newCar(); Car y = x; x.carNumber=1; y.carNumber =2; Console.WriteLine (x.carNumber); Console.ReadKey(); ﻛﻮد VB Dim x As Car = newCar() Dim y As Car = x x.carNumber = 1 y.carNumber = 2 Console.WriteLine(x.carNumber) Console.ReadKey() ﻛﻮد אل1Q Car Class K´ . ، Clone 1 53 $ 9 Car nF\ אClass אل53 77 + KF . CloneدאאلP.وCloneaple Interface اﻟﻤﻘﺎرﻧﺎت .10 ، H7F C# U ==K3\وאC = K3\ אY4\ אGم א$+Q ، Qא$ א17N AIC i3 $N :^ذ3אaא C# if (x==y) { ﻛﻮد } VB if x=y Then End if ﻛﻮد 121 NS و$V7و،مאو$DU False 'نPF!אوU True V[ אF7'نאP .1'אعא9אnDa7!1NQ אWS5Pو، "Ahmed"="Ahmed" وC7=7אو5=5:ً ^3K3Pאوא ﻣﻼﺣﻈﺔ ... وغيرھاInt , Long , String األنواع البسيطة ھي االنوع مثل : ً MQא\^لאא03N,Kb'אN C# string a = new string(new char[] { 'h', 'e', 'l', 'l', 'o' }); string b = new string(new char[] { 'h', 'e', 'l', 'l', 'o' }); Console.WriteLine(a == b); ﻛﻮد VB Dim a As New String(New Char() {"h"C, "e"C, "l"C, "l"C, "o"C}) Dim b As New String(New Char() {"h"C, "e"C, "l"C, "l"C, "o"C}) Console.WriteLine(a = b) ﻛﻮد :א1 'دPאNFذא'א35Pو،ًMQ אTrue `NאK(LאlWSU C# object c = a; object d = b; Console.WriteLine (c==d); ﻛﻮد VB Dim c As Object = a Dim d As Object = b Console.WriteLine(c = d) ﻛﻮد L אlWSUKLא، False 'نP2N نא−a7!XH,אU − o N&G+א1א : EqualsK3\אمא$+ C# Console.WriteLine (c.Equals(d)); ﻛﻮد VB Console.WriteLine(c.Equals(d)) ﻛﻮد 122 :ض א\^لאZON،ً ^3 Structs אلYH7F Equals K3FIאم$+א C# struct car { public int carNumber; }; ﻛﻮد VB struct car { public int carNumber; }; ﻛﻮد :אh אq\אoQ NF.'،وאن C# Car x = new Car(); x.carNumber=1; Car y=x; Console.WriteLine (x==y); ﻛﻮد VB Dim x As New Car() x.carNumber = 1 Dim y As Car = x Console.WriteLine(x = y) ﻛﻮد False nSo ؟؟؟True SD'1\'نאאPضאنZO\א،:.'Wא2N'אS3 .]1I1אWSن :א7Q1 Equals K3\אمא$+'SRVאKLא C# Console.WriteLine (x.Equals(y)); ﻛﻮد 123 VB Console.WriteLine(x.Equals(y)) ﻛﻮد :אKPTًMQאم==א$+א5P>، Classes oQU C# Console.WriteLine (Class1==Class2); ﻛﻮد VB Console.WriteLine(Class1 = Class2) ﻛﻮد ؟True ً Fjدא2N'نאPQ\ذאfKS،א\^لאUF Equals وC 2NאنאWiאWאUنP\@אON אنTQنNjPאنא4+ CS'عs'\אאWk71N\א%9א : אKPTTrue :ضא\^لאZON،RbאWSو C# Car x = new Car(); Car y = new Car(); x.carNumber=1; y.carNumber = 1; Console.WriteLine (x==y); Console.ReadKey(); ﻛﻮد 124 VB Dim x As New Car() Dim y As New Car() x.carNumber = 1 y.carNumber = 1 ﻛﻮد Console.WriteLine(x = y) Console.ReadKey() :אKPTدאPKL א،i$وאFkIא$*אjV אنאFalse ... S`N'نאP C# bool isthesame(Car c1,Car c2) { if (c1.carNumber==c2.carNumber) return true; return false; } ﻛﻮد VB Private Function isthesame(ByVal c1 As Car, ByVal c2 As Car) As Boolean If c1.carNumber = c2.carNumber Then Return True End If Return False End Function ﻛﻮد ؟q\א53i$Q$%+ KFDUGN'ذא35P :אKPT Clone C$3م$+LאlWSU C# Car doCopy(Car c1) { Car newCar = new Car(); newCar.carNumber=c1.carNumber; // // return newCar; } ﻛﻮد 125 VB Private Function doCopy(ByVal c1 As Car) As Car Dim newCar As New Car() newCar.carNumber = c1.carNumber ' ' Return newCar End Function ﻛﻮد g% א'א53 7T3 J! א، sאZ! אiH'V i'د%'3 Clone א$ א${ 9 אbN א53 ^ U F. وClass JO א4 'م7 53 אN ' ،i,3 אم$+ iS% א$ אlWS $`ICloneaple nD b אJO'ن אP r g4 'م7 i'د%'3 Clone א$ א$`! 7 אJO א53 g.7, . i,3k Clone KFD53JOم$+3א01Q،7 אQ\א Nullable Types .11 'dאن$9ً ^3 Boolean 'ع53 q\!، ً . 'א73 Null F7א$Q$7אh אq\אfDU U،אWPSو...ً ^3 32767وOVאY3م.HאnD'dאن$9 Short q\א، False وC True nD . reference 'ع53g null F7אXא01 String ً ^3VNא7 אY 5QHد. NאnN} ( Null− F.9)F. Boolean 71N3 q3KFdن1Mن9אUNNP 43Gא:%'אtאQ$7אPT\אS^ذ3אaא، False وC True ذאنF!$Q$nD م$+\ض אنאONو،(وج3)K75Pو3K7UF7م$+\لאIمאد$DUh א$D'א. مQن3'Sو، null F7 ªOdK7LאK(LאlWSU،:3$D53ً%و3*+Tد'نא$d_ .ً ^3 bool 'ع53 q3 אUgsوK. Null gאnD CheckKFD null F7אK7F*V q3oQنP39b א.net framework 53^ אiHא$b9א03و5P :א\^لאUF،:9א7!sא C# bool? ismarried = null; ﻛﻮد 126 VB Dim ismarried As System.Nullable(Of Boolean) = Nothing ﻛﻮد Null SLאF7'نא537دونאhאi$D.53i,3F.izא7 lدNאNNP>LאlWSU :MQאא7Q1 אK^3 Null K7Q q3oQAIقאi$D¤NS C# Nullable<bool> nullableBool = null; ﻛﻮد UlN3 nDfN3'Sو، System.Nullable<T> nF\ אgeneric KHVI!ًאS ? אن .XPא533د.zא%C :אKPT'نذP! Nullable k return 'نאلPQدאoQدH'אF! 7Q1@אONو C# public bool? functionName() { ﻛﻮد } VB Public Function functionName() As System.Nullable(Of Boolean) ﻛﻮد End Function Nullable ﺧﺼﺎﺋﺺ ال .11.1 ªOd : אم אF. : q\ ذא ن אF! د$ t وאHasValue bI S nullable * אلjVI Sא :אKPT Null F7 C# if (ismarried.HasValue) { ﻛﻮد } 127 VB If ismarried.HasValue Then ﻛﻮد End If :אKPT`'אلO אU <> وC=!ًMQאH7\אKjאمو$+g5P> C# if (ismarried!=null) ﻛﻮد VB if ismarried<>nothing then ﻛﻮد ﻣﻼﺣﻈﺔ في السي شاربnull خاصة بالفيجوال بيسك بدال ً منnothing ال تنس أن ” اﻟﻤﻌﺎﻣﻞ “؟؟ .11.2 ضZON، null XS'د%وU3F.0s'l4µP nullable אل7א03؟؟K3\אمא$+א5P> אنnN}XD*א+,'g!אوאجhلIد7Q_*+,ضאنאZONو،^لאوאج א3 :ذK%א53'دאPאP'م7N،i,3 False VF7א C# int? ismarried = returnvaluefromdatabase() ?? False; ﻛﻮد VB Dim ismarried As System.Nullable(Of Integer) = IIf(returnvaluefromdatabase() Is Nothing, [False], returnvaluefromdatabase()) ﻛﻮد 128 129 اﻟﺒﺎب 8 اﻟﻔﺌﺎت وﻣﻘﺪﻣﺔ إﻟﻰ اﻟﺒﺮﻣﺠﺔ ﻛﺎﺋﻨﻴﺔ اﻟﺘﻮﺟﻪ 130 131 Classes ﻣﻘﺪﻣﺔ إﻟﻰ اﻟﻔﺌﺎت .1 i$ وאJ! nD 'd Console Application ]TN\ א234 !¦ن א، 7 אNوH دU N(9 F N! 0. א'אU ... وقhאzא% وאh אq3 دوאل وnD gIא$ ' class Program lF3 . Class JO'אS OOP ¨د31Q239א HU،:Iא$hJ!i$DnDًMQאJOאن'א5P>و،hJ! i$DnD234'אdאن5P> . Project 53 New Class !sאNP>KVON3 Class KFD U وCXH,אU{}Y:'P3oQ Q،:א53 وClass iא[`'زFPאمא$+JOאoQQ ، Person gF وi$Q$% J! אجH'م د7N ، VB.net U End Classn oQ אB $ 53 :sאZ! אiH'Vً'دא%'3'دאPא$`N C# namespace ConsoleApplication4 { class Person { } } ﻛﻮد VB Namespace ConsoleApplication4 Class Person ﻛﻮد End Class End Namespace i'د%'\ אClasses hJO א0B א אنWS cQ ، Hوs namespace د אل$d W אول אzא لI53 i$Q$ אJOא03K3א535PFNאW،IאgM Q¯HgNP> namespace @אلO . Program lF\א9אJO אUNbאmain 132 JOאKIدאF وאIאولوא9אh!s^ ًא3NNP>،h אq\אS ClassJ!Ch'P3aא :אKPTClass C# class Person { public string FirstName; public string LastName; public int Age; } ﻛﻮد VB Class Person ﻛﻮد Public FirstName As String Public LastName As String Public Age As Integer End Class :ً ^3אKPTJO אlWS53 Objects hNji$DoQ5P>אن C# Person Ahmed = new Person(); Ahmed.Age = 15; Ahmed.FirstName = "Ahmed"; Ahmed.LastName = "Gamal"; Person Ali = new Person(); Ali.Age = 15; Ali.FirstName = "Ahmed"; Ali.LastName = "Gamal"; ﻛﻮد VB Dim Ahmed As New Person() Ahmed.Age = 15 Ahmed.FirstName = "Ahmed" Ahmed.LastName = "Gamal" Dim Ali As New Person() Ali.Age = 15 Ali.FirstName = "Ahmed" Ali.LastName = "Gamal" ﻛﻮد 133 :אKPT!'OV3 KP,nDgOQ5P>وC C# Person [] MyEmpolyee = new Person[3]; MyEmpolyee[0] = new Person(); MyEmpolyee[0].FirstName = "Ahmed"; MyEmpolyee[0].LastName = "Gamal"; MyEmpolyee[0].Age = 15; ﻛﻮد VB Dim MyEmpolyee As Person() = New Person(2) {} MyEmpolyee(0) = New Person() MyEmpolyee(0).FirstName = "Ahmed" MyEmpolyee(0).LastName = "Gamal" MyEmpolyee(0).Age = 15 ﻛﻮد N$دא4'م7N،ClassJOאKIوאلدא$אoQًMQאNP3 !¦ن، Struct אلUذF :אKPT'نP،Y3*+TK3P א9א C# ﻛﻮد public string getFullName() { return FirstName + LastName; } VB Public Function getFullName() As String Return FirstName + LastName End Function ﻛﻮد 134 Constructors اﻟﻤﺸﻴﺪات .1.1 tאא$אSو، Constructorאאل$אKqT'م7NאcQאWS !¦نnew Person() oQ'م73$ND t אg!3وא9 א0s وNNP> وI א$ אlWS'نP ً sאZ! א، 234 א53 + אKqT 03 KF :ClassJOא53i$Q$%+ zT4§Hً ^3ض،+zTא.وg% C# public Person() { Console.WriteLine("new object"); } ﻛﻮد VB Public Sub New() Console.WriteLine("new object") End Sub ﻛﻮد ﻣﻼﺣﻈﺔ اما في فيجوال بيسك فيتم تسمية الدالة، في السي شارب يتم عمل دالة بنفس اسم الفئة New باسم 03 אول9 אK7Q Constructor אلK ً ^F! ، hאZ3H Constructor אلK7Q ً אنMQ א5P> :אKPT'نذP!،$Q$אP´و9 אoQ C# ﻛﻮد public Person(string userfirstname) { FirstName = userfirstname; } VB Public Sub New(ByVal userfirstname As String) FirstName = userfirstname End Sub ﻛﻮد :'دאP אNDG%'i$Q$%+KFو 135 C# Person MyEmpolyee = new Person("ahmed"); ﻛﻮد VB Dim MyEmpolyee As New Person("ahmed") ﻛﻮد Destructor اﻟﻤﻬﺪﻣﺎت .1.2 ً ^3 Beep h'bHא$b9، Object אمאل$+אzgא03E$LאאWSא قQ، Constructor @אلPD :234אzgא03 C# ~Person() { Console.Beep(); } ﻛﻮد VB Protected Overrides Sub Finalize() End Sub ﻛﻮد 3 ج3ًא،ً3eObject5jP א3$K.hFאWONU Destructor אل53$O q :3א$+ א5P> ً MQ א، E$Lא אWk g,9אم א$+9' אS وiאW אU : 1\ אh אq\ א0B .N3 J!53¢Nא$'م7t^ ًوא3hאدא$א this .2 Wوא،i,3سאH$אU'د א\^لN،XH,אU this iא[`'زFP'مאgO3s' :אKPT Constructor KF:!NF. C# ﻛﻮد public Person(string userfirstname) { FirstName = userfirstname; } 136 VB Public Sub New(ByVal userfirstname As String) FirstName = userfirstname End Sub ﻛﻮد :ً ^3אKPT FirstName 'نPZ3H אאq 'م7NNאنאNsZ!'א C# public Person(string FirstName) { FirstName = FirstName; } ﻛﻮد VB Public Sub New(ByVal FirstName As String) FirstName = FirstName End Sub ﻛﻮد (NQ 5 و، :O وQ Z3H אFirstName K{ אQ3'P אgO o L אlWS U = P´و9 אU 'د%'\ אq\ אن א$V7 ¦ Q3'P אoQ . P´و9 א5Fs qF FirstName U 'د%'\ אq\ אT t وאVB.net U Me وC C# U this FPم א$+N K\ אZ3Hא :LאP´و9א C# public Person(string FirstName) { this.FirstName = FirstName; } ﻛﻮد VB Public Sub New(ByVal FirstName As String) Me.FirstName = FirstName End Sub ﻛﻮد a א، ً Fj دאGN3 'نP this אم$+ !¦ن א، س אH$ אU k N.1 t א7 אL אU n . thisg!GP t(אRאWN34א.وP´و9אUi'د%'\אbNFj.Hg&'אS ذXא 137 Static اﻟﺘﻌﺮف ﻋﻠﻰ .3 S&N\!s אC# אلU static FPم א$+Nא234אUًאi'د%'\ אmain א$אUN(9 ؟FPאlWSnN3F!، VB.net אلUShared Qא$ אوאq\אאWSאنch אq\אnאوhJOوאل אوא$א03g3א$+א5P>t وאstatic FPא Xضא\^لאאصZON، object אلA'353@وi,3 Class אلA'3 nD53k'لb'א :Person C# class Person { public string FirstName; public string LastName; public int Age; static public int counter; } ﻛﻮد VB Class Person Public FirstName As String Public LastName As String Public Age As Integer Public Shared counter As Integer End Class ﻛﻮد :ً ^3'دאPאN NضאZONو C# Person MyEmpolyee = new Person(); MyEmpolyee.Age = 15; MyEmpolyee.counter = 3; ﻛﻮد VB Dim MyEmpolyee As New Person() MyEmpolyee.Age = 15 MyEmpolyee.counter = 3 ﻛﻮد 138 A'3nDi,3:zא.אW وstatic q3'S counter אن،ًRRb 'دPאאWS'نPQ5o :אKPT ClassJOא C# Person MyEmpolyee = new Person(); MyEmpolyee.Age = 15; Person.counter = 3; ﻛﻮد VB Dim MyEmpolyee As New Person() MyEmpolyee.Age = 15; Person.counter = 3; ﻛﻮد ClassJOאKIدא53:b אcounterאلF.ضNF.و،JO@ אO53$Q$% Object oQNF.' 0F Class JO אA'3 nD :N3 i$ وא+ oQ Q static q\ ذ אن א، i,3 3 g א$`N .:N3gFDQtאobjecthNjPא אWS53S]TNt@אP´و9א$'م7tوא،hאدא$אbISbאlWS53 iدO9אnD^ل3 : Destructor UنV7N'دא0MF! ConstructorאلU!s9'دאPא0MN،ClassJOא C# class Person { public string FirstName; public string LastName; public int Age; static public int counter; public string getFullName() { return FirstName + LastName; } public Person() { counter++; } ~Person() { counter--; } } ﻛﻮد 139 VB Class Person Public FirstName As String Public LastName As String Public Age As Integer ﻛﻮد Public Shared counter As Integer Public Function getFullName() As String Return FirstName + LastName End Function Public Sub New() counter += 1 End Sub Protected Overrides Sub Finalize() Try counter -= 1 Finally MyBase.Finalize() End Try End Sub End Class :אد$אF.'مض753و،hNjPא53د$DzT 'م7Nوאن C# Person MyEmpolyee = new Person(); Person MyEmpolyee2 = new Person(); Person MyEmpolyee3 = new Person(); Person MyEmpolyee4 = new Person(); Person MyEmpolyee5 = new Person(); Console.WriteLine(Person.counter); ﻛﻮد VB Dim MyEmpolyee As New Person() Dim MyEmpolyee2 As New Person() Dim MyEmpolyee3 As New Person() ﻛﻮد 140 Dim MyEmpolyee4 As New Person() Dim MyEmpolyee5 As New Person() Console.WriteLine(Person.counter) :'دאPאNsZ!وאن'א C# Person [] MyEmpolyee = new Person[5]; Console.WriteLine(Person.counter); ﻛﻮد VB Dim MyEmpolyee As Person() = New Person(4) {} Console.WriteLine(Person.counter) ﻛﻮد Q_ MyEmpolyee ¢53ًQאن אGوא،:)U@.'o ، 5'نP2Nאنא0.'9 :52Nא153SאLא،$lzTא C# Person [] MyEmpolyee = new Person[5]; for (int i = 0; i < 5; i++) MyEmpolyee[0] = new Person(); Console.WriteLine(Person.counter); ﻛﻮد VB Dim MyEmpolyee As Person() = New Person(4) {} For i As Integer = 0 To 4 MyEmpolyee(0) = New Person() Next Console.WriteLine(Person.counter) ﻛﻮد Static Class .3.1 $9 Static Class Cل!¦نLא1و، Static Class אلC$3دFD א.net framewrok 2.0 WN3 object oQ71N\א53@:¦!ذosא، static 'ع53:!وאل$ وאh אq\א0B'نPאن . New אم$+ClassJOא אWS53 141 MessageBox S ClassאאلWS^3אaא،i,3 ودوאClassJOאم א$+א5P>LאlWSU .gN3+oQدونi,3g3א$+ א5P>tوא C# MessageBox.Show(“Welcome”); ﻛﻮد VB MessageBox.Show(“Welcome”) ﻛﻮد OverLoading اﻋﺎدة اﻟﺘﺤﻤﻴﻞ .4 @ONقאودوאلi$DF 5P>، Overloading ¨אل$31S OOP د¨אل3Sא53 .سZ3HאU q¤NSدאم39א : Windows Forms אلU MessageBox.Show() دאS Overloading אلhFDnD^ل3aא :ً ^33אوאlWS $`%' ﻛﻮد MessageBox.Show(string text) MessageBox.Show(string text,string caption) MessageBox.Show(string text, string caption, MessageBoxButtons buttons) C$35PQ_'H'VN،9@אOًB kوbIدא5DiHDgN3i$وאK،3אوא75FsًMQאS و :אKPT دوאلP1MNN،ً'دא%'3Overloading ﻛﻮد MessageBox.ShowWithString(string text) MessageBox.ShowStringAndCaption(string text,string caption) MessageBox.ShowStringAndCaptionAndButtons(string text, string caption, MessageBoxButtons buttons) . אم$+9'אg GQ3אWSو،9@אONًBS${אم$+9אKgאنو3C 142 אYUً ^30FאF−אKPT'دNP> دوאU OverLoading אلC$31 : double - 'ع53 אوint 'ع53.ClassJOאUH> KSH$9 C# static int Add(int x, int y) { return x + y; } static double Add(double x, double y) { return x + y; } static long Add(long x, long y) { return x + y; } ﻛﻮد VB Private Shared Function Add(ByVal x As Integer, ByVal y As Integer) As Integer Return x + y End Function Private Shared Function Add(ByVal x As Double, ByVal y As Double) As Double Return x + y End Function Private Shared Function Add(ByVal x As Long, ByVal y As Long) As Long Return x + y End Function ﻛﻮد '،م$+\אجאGgN3د$DKFDNPF!، Constructor אل03AIC i3iPא$אن5P> : אKPT Constructors אلoQ5P> Person N^\ $D C# class Person { public string FirstName; public string LastName; public int Age; public Person() { Console.WriteLine("c1"); ﻛﻮد 143 } public Person(string fname,string lname) { FirstName = fname; LastName = lname; Console.WriteLine("c2"); } public Person(string fname,string lname,int myage) { FirstName = fname; LastName = lname; Age = myage; Console.WriteLine("c3"); } } VB Class Person Public FirstName As String Public LastName As String Public Age As Integer ﻛﻮد Public Sub New() Console.WriteLine("c1") End Sub Public Sub New(ByVal fname As String, ByVal lname As String) FirstName = fname LastName = lname Console.WriteLine("c2") End Sub Public Sub New(ByVal fname As String, ByVal lname As String, ByVal myage As Integer) FirstName = fname LastName = lname Age = myage Console.WriteLine("c3") End Sub End Class :قא1א$] hNjzTאNNP>7Q1אlWgو C# Person MyEmpolyee = new Person(); Person MyEmpolyee = new Person("ahmed","gamal"); Person MyEmpolyee = new Person("ahmed", "gamal",22); ﻛﻮد 144 VB Dim MyEmpolyee As New Person() Dim MyEmpolyee As New Person("ahmed", "gamal") Dim MyEmpolyee As New Person("ahmed", "gamal", 22) ﻛﻮد Access Modifier ﻣﻌﺮﻓﺎت اﻟﻮﺻﻮل .5 NQאWSوذאن، public 'S:3א$+ 'م7WאsאZ!9'لאb'אf3ن،7אNوHدU f\ אN3$+ ' אN ً MQ אN. ، Object ل אلI 53 i,3 q\א אWS وC א$ אlWS 'لb'א a7! :O Class JO אKI دא53 A' א$ אlWS אوq\א אWS Q¯H 53 5PF 5! Private .gNh.وOوאO+\'ل אb'אh!3א'אعnDff'سH$אאWSU : Public JOق א7, $C م. ' ً MQ א، i,3 Object אل53 q\و אC א$'ل אb' אf\א אWS Q .k'لb'א$Q$אClassJOא53 objects K5PFوSF public א$אlWS$`!Class : Private .: I53:OQW אStruct אوאلClassJO אKIدא:Q¯Ha7!5P> : Protected .T\אClassJO א53k'لb'א5P>5P وObject אل53k,\'لאb'א5P>9 : internal .a7! Lא9אKIدאk'لb'א5P> : protected internal .9אo3@O لI53k'لb'!sאT\אClass JO لאI53ًMQאk'لb'א5P> 145 OOP اﻟﻌﻨﺎﺻﺮ اﻻﺳﺎﺳﻴﺔ ﻓﻲ .6 :אE ^ط א7Nאنض$9 OOP د¨אل31tא4אhq0B Encapsulation .1 Inheritance .2 Polymorphism .3 : Encapsulation .6.1 nD م$+F QgN אU SHg& وאO+\ وא'אد אh אs وzOI' אS Encapsulation ل$V7Q 'د%'\'دאP'אS3FgQ90.א'אU، PrintReport دאQgNאU$` ، Black Box KP, .QH7אDدאQ$KFSzD$אOPQ،gIدא Structured X'KFאLאU،وعT\אnDDF אKFאUbאlWS53ًMQא$O KFא53z%K'نP! OOP אلU Encapsulation אل033א،$ن وאP3U'دPא0B$` KF אGKgUSQ3אWSو،O Objects Q5DאgNKbא'אQ و:OnDً7q3 .z1IאfTאKg، : Inheritance .6.2 KQ$وCSQ'1K%א53:VjVI@OnD'ClassJOא53 i$Q$%+KFDg$V7Qو،אH'وאC .ً ^3gNb¢QHوiHאאnD'd(iH)ClassJ!NQ$^ ًאن3 ضZON،*jVא ClassJ!KF'م7]אن1א53LאlWSU،ً ^3 BMW אلhאH ClassJ!KFم7א$Qوאن isSport bI!sא03 Car nF\ אClassJOא53$Q$% ClassJ!ق7, א01NNPو،kKVON3 ًMQ א، BMW و אلCar אلY ZT3 *jVI $`N N ذ א53 f$k א، BMW lF\ אClass JO .ZT3hnDlHو$'RW وאGMC KJ! !s9ً3'Q1MN 146 0BUKQ$'م7NKg! ،hאHאKP countofdoors K^3$Q$%VND!sNF.'IאGא .h Q$א1a7!:!KQ$א01N¦! Car JOא53ق7,אKFNF.U،hJOא .hא53 'د%وUi$jO` אK§015Pوi qVאhJOאUFSאg(9}H لP, J! 'د%وUًMQא، BMW is a car אن، is a Inheritance . אoQ Q .Circle is a shape^ ً!¦ن3ijא$AICJ!و LאlWSU، aggregationnF وhas a . DS وClasses אلYh. א53I'ع¤NS ، Wheels iH אh `D K% א53 J! NQ$ ^ ً ' ن3 ، אوJO אnD Q') ^ אJO'ن אP .Car has a wheel'نP : Polymorphism .6.3 H%'אSGوא، Implementationونא$ kوא$ J!P vF'אS OOP ¨د353 IאC$\א ^ل3 aא،z9א:T5FMQ}وאل$אlWk implementation KF JOقא7, 'م7Qم$+3א :אKPT:OQNNP>، Shape ~ClassJ!ذnD C# class Shape { public void Draw() { } public void GetSize() { } } ﻛﻮد VB Class Shape Public Sub Draw() End Sub ﻛﻮد 147 Public Sub GetSize() End Sub End Class ً^ א:TQW وאInterfaceאلC$3ًMQ אC# !'، Abstract Class Class אلfQLאlWSU .gNUgDfNh.!و035P وAbstract Class אل א'אدnDًא4'نP JOאאWS 53:.7,^(א3،03،ij )دאJ!K א!¦نJOאU .gN3KP\אXאو default 'د% وF אU f I9 א03 5P وOverRidding אل4D AIC 7Q1 ذKFD 5P> .Implementation Encapsulation .7 YD א5D J! Iא$ אKbO אzOI אHVI :, W وאEncapsulation אلC$3 f$gQ 53و،VIو،زن+\אiHدא9(م5FMQ¶)ض(مZON$Q$, HVI،Y4\א. .h\ אK%א وאل$ א53 د$) د$D (N אlWS 53 $ وאKP 'نP Encapsulation אلC$3 ¤'D$Q L אlWS U ${ h\مאP(Uً ^F!،k I53Kb(א^ א'אN5P>t(موאNאאWS 53'لوאوجI$ .وאل$א53 ًא$%iود$)D'FUא...(VI)(hQZT3!s()אh3FD!s)א $]وאhאi$D.!5FMQ،3אوא53ًאH'G1h3FD !sאK^3FD(אن9'ً gF{،h אi$D.U2Nא5Q§53وFP'دא%و53$]وאRRbI$\אhאن א53 53ً9$:3א$+مא$+\אhg%وא4 'م7QWאIא3'مز7Q$وא3CKP,nDQgNאU .NOאKbOאlWSKU'صqא ¤'دgOًא1M3א'ن5،ً9אوhD'FU KFtصא+,'عאs'\אאWS$OQ،(9F :Q3CKمSKP,nDًFFV3'نP'دPאنאF،3K3 אofDאنאcOPQوK3P 148 53 ^ ًאK7Q 3 'Sم وkس אCH 'لb' a7! ًאHد. 234\ א3'ن زP 5P ، 3 אوא53 D'F .5QIאY4\ א53]1אQ5Dgא53b אאq3FdF،z1Iא ط7Nא53$Q$א¤NS'مgO\אאWS1و، OOP hqK:b' ولאنW'مאgO\אאWS .سH$אאWSUkق1N tא ً ^3nN}...م$+\'אSI2343¤NSو2343CNSذUgMאن$9 17ولC،Kbאن'אK. .وعT\א53z`JOאWSאم$+234\א3'مز7QوJ!4'م7 א private ﻟﻠﻮﺻﻮل إﻟﻰ ﻣﺘﻐﻴﺮاتpublic اﺳﺘﺨﺪام دوال .7.1 :7وسאH$אA'3nDhא3i$DlzTNF.W אPerson 'صאلVx ضא\^لאZON C# class Person { public int Salary; } ﻛﻮد VB Class Person ﻛﻮد Public Salary As Integer End Class :אFאPم.−'gQ953K%و−Thل אIאصدQOאUQא3ونز C# Person Ahmed = new Person(); Ahmed.Age = 999999999999; ﻛﻮد VB Dim Ahmed As New Person() Ahmed.Age = 999999999999 ﻛﻮد 149 aوא،0.'אX.אz,אUPT\אlWkض$.NNP،KR3:,$Q`Lא אWg.HU'gو'אنא K^3!¦ن- @ - م$+3'د%وUو،i,3g م$+\א53F7אizא7'م7Q:ذ'א53 .ً ًא3C$h I$\ אlWS }H لIد9אh,,23433אنزF، gFF.W אJOK%אH3$אG KI$\אאWSً H'g( א53 אq3 0N3 א، Fjא$ אRVNא ] אW ، لIد9 א53 7R א3 אzND :O oPQ 5 :אKPTgP אوאgzא7دوאلgN3ً9$0sو−Iא234\א−g3$+\ C# class person { private int Age; public string SetAge(int x) { if(x>100 || x<1) return "you can't edit age like that"; ﻛﻮد Age=x; return "done"; } public int GetAge() { return Age; } } VB Class person Private Age As Integer Public Function SetAge(ByVal x As Integer) As String If x > 100 OrElse x < 1 Then Return "you can't edit age like that" End If Age = x Return "done" End Function Public Function GetAge() As Integer Return Age End Function End Class ﻛﻮد 150 وذ− ً ^3 אKPT אWI] אنqNQ Set دא، ً 7 N7O אF 1I'S x h אq\ אF ً :−سאH$אU Me وC this *jVI53NFF C# public string SetAge(int Age) { if(Age>100 || Age<1) return "you can't edit age like that"; ﻛﻮد this.Age=Age; return "done"; } VB Public Function SetAge(ByVal Age As Integer) As String If Age > 100 OrElse Age < 1 Then Return "you can't edit age like that" End If ﻛﻮد Me.Age = Age Return "done" End Function zNq9 א5P>9Q'ً7$Q$א0QHT\אUH'3אlWSK^3:NP،ً Q' ًאو3وא$Q}H .a]1IGYQ 3i$DoPQوعT\'ط7UG$.ggND ﻣﻼﺣﻈﺔ . Mutator فتسمى باسمSetAge أما الدالةAccessor يطلق عليھا اسمGetAge الدالة : Constructor ارﺳﺎل اﻟﻘﻴﻢ ﻛﺠﺰء ﻣﻦ ال .7.2 hאZ3H QFم$+FbOאאSو،7א7Q1א03אوKQ$g3א$+ אNP>AIC7Q אو7Q1אمא$+אDً3'ن אPi P אhJOאU، Constructor $T\א5Fsh אq\א. 151 אل53 Object zT(אLh אq\אK.QF'م7Qم$+\ אH'V5א7Q1אlWSG% .Class :7Q1אlWS^ل3 C# class Person { private int Age; public Person(int Age) { if(Age>100 || Age<1) return "you can't edit age like that"; ﻛﻮد this.Age=Age; return "done"; } } VB Class Person Private Age As Integer Public Sub New(ByVal Age As Integer) If Age > 100 OrElse Age < 1 Then Return "you can't edit age like that" End If Me.Age = Age Return "done" End Sub End Class ﻛﻮد 152 : Type Property اﺳﺘﺨﺪام ال .7.3 و: Set دאنgN3KPbI q\אKQ'nDًدאFDوאAIא7Q1 5Pو،7א7Q1@אON :אKPTذQ ،Get C# class Person { public int Age { get { return Age;} set { if (!(value>100 || value<1)) Age=value; } } } ﻛﻮد VB Class Person ﻛﻮد public Property Age() As Integer Get Return Age End Get Set If Not (value > 100 OrElse value < 1) Then Age = value End If End Set End Property End Class z,G Uو، Set zD$אz,א1K.5Pو، Age ,\'لאb'אNP> وאن hFDnDhF אKFDلאوIد9אh53$]אQ3'Sو، Get 53:D'لVLא אجI9א S Age lF\(אLאlWSU q\)و@אbنא9 public FS Get وSet نCًMQ( א9 153 ،i$nD Get אوSet X'لאصb'אf3UKQ$אP3b א.net 2.0 WN35Pو، public :ً ^3אKPT C# public int Age { get { return Age; } protected set { Age = value; } } ﻛﻮد VB Public Property Age() As Integer ﻛﻮد Get Return Age End Get Protected Set Age = value End Set End Property KF @P אhدH ' א3C ، Set b אزא אNPF! Read Only Property KFD U G N ذא : Read Only Propertyאא\^للWS، Get b!]زلאWrite Only Property C# public int Age { get { return Age; } } ﻛﻮد VB Public ReadOnly Property Age() As Integer Get Return Age End Get End Property ﻛﻮد 154 Inheritance اﻟﻮراﺛﺔ .8 وسHدU Encapsulation 'مאولgO\ אvTNF.،אbNDE k OOP سאنHدUذ . Inheritance אل03$D'3وאن،7 :אصlN, Wضא\^لאאZON،KFא:30^ل3KFC$Nאن C# class Car { private string carName; private int carModel; public Car(string carName, int carNumber) { this.carNme=carName; this.carNumber=carNumber; } public Car() { carName="Unknown"; carNumber=0; } } ﻛﻮد VB Class Car ﻛﻮد Private carName As String Private carModel As Integer Public Sub New(ByVal carName As String, ByVal carNumber As Integer) Me.carNme = carName Me.carNumber = carNumber End Sub Public Sub New() carName = "Unknown" carNumber = 0 End Sub End Class .سH$אאWSKא3 لI:NوlQ'1nD KFא0و،aאא\^لאWgC$N 155 is-a :ﺗﻌﺮﻳﻒ ﻋﻼﻗﺔ .8.1 'عאولNאv,ولאنRN،has-a'نP$. وis-a 'نP$.. !¦ن א،TD0سאH$אUذF : BMW iHضZON،jאJO'عא53'S7T\אJOאنאcQW وאh. א53 C# class BMW: Car { } ﻛﻮد VB Class BMW Inherits Car ﻛﻮد End Class @O وCar X אClassJO*אjVI@OnD'd BMW 59 אClassJO'لאنא7אن01אWPS carName bא,\'لאb'ولא59אJOאUNض אZON5Pو،a7! public אل:.و:دوא :17NאlWSs'Qאא\^لWS ،ذ535PF5! C# BMW ahmedcar=new BMW(); ahmedcar.carName="anyname"; ﻛﻮد VB Dim ahmedcar As New BMW() ahmedcar.carName = "anyname" ﻛﻮد NضאZON،bאlWS'لb'א01r 7T\ אJOאKIوאلدא$ אoQNF.'n :אKPT'نP BMW JOאb $Dא C# class BMW: Car { public changeCarName(string value) { ﻛﻮد 156 carName=value; } } VB Class BMW Inherits Car Public Sub New(ByVal value As String) carName = value End Sub End Class ﻛﻮد 'لb'אf3אنoTP'لb'אh!3سH'عد% א،ً3eًRRbאWS'نPQ5o : אprotected 'لb' אf3 م$+ אWS K% א53 ، 7T\ אJO א53 : 'لb' א5P> 9 private 'لb' א5P>K7\אU:NP، object لאلI53:,\'لאb'א5P>9:'U private אل:TQ : אKPT Car JO^لא3NsZ!'א،7T\אJOאKIدא53: C# class Car { protected string carName; protected int carModel; } ﻛﻮد VB Class Car Protected carName As String Protected carModel As Integer End Class ﻛﻮد 'نPQ f' אW ، h אq\ אlWS izא7 'م7 BMW 7T\ אJO אKI دא دאoQ NNP> L אlWS U :ًRRb'دאPא C# class BMW: Car{ public changeCarName(string value) { carName=value; } } ﻛﻮد 157 VB Class BMW Inherits Car Public Sub New(ByVal value As String) carName = value End Sub End Class ﻛﻮد NotInheritable - sealed اﻟﻜﻠﻤﺔ اﻟﻤﺤﺠﻮزة .8.2 :אKPTذQ،:N3ق7,9א5P>9JOא אWSאنFPאlWSאم$+אcQ C# sealed class Car { ﻛﻮد } VB NotInheritable Class Car ﻛﻮد End Class ﻣﻼﺣﻈﺔ C# فيsealed تقابلNotInheritable الكلمة اﻟﻮراﺛﺔ اﻟﻤﺘﻌﺪدة .8.3 nN3، managed c++ a7!:71 YU،iد$\אאH' אC$3 VB.net אوאلXH,אq!'9 U،iH J!وN, J!NQ$ضZON، J!53^ א53Tאن3J!نP3אنiد$\אאH'אF 5P و،QאدiHوאNT*אjVInD'd$Q$%'عKFD01N¦!iد$\א אH'3qDد VB.net .אوאلXH,א53Kl!'93אWS 158 FN:DfN3'Sو، interface 53^9 Implementation KFDندqمא$7،WKQ$و .zאאWSKV :s'aאאאWS¦!، VB.net وC# Uiد$\אאH'אDو'!دPQ3م$7_\ذא3C رابط http://blogs.msdn.com/csharpfaq/archive/2004/03/07/85562.aspx اﻟﺘﻌﺪﻳﻞ ﻓﻲ اﻟﻔﺌﺎت اﻟﻤﺸﺘﻘﺔ .8.4 U، i$Q$ אJOودوאلאEא$C*وقوjVInDi,3KQ$אNNP> ،7وسאH$אUNQCHF د$DnD' BMW JOi$Q$%bI!sאNNP>،9 אqNF!دאsNF.א\^ل א ...אWPSو، BMW'ع53hאHאU!sאiFiHאKI'ندאQOאig%C ' 5P . ¤RF אhROد א$D !s אNNP> L אlWS U ، H ! אAIC J! KFD NNP> Car 9 אJO אU g!s אOP! hאH א0F maxSpeedbI oQ א3 U N`א .ً BzNאhJOאUًj7i'د%'3S$`و ،gT\אbN3Di$D.0sوS אH'אFjא$j'אOא53i$אنوאª אن01NS53 Uًق אOא${5}H،hא3i$DgN3KHאPiدD א53ً9$a7!f I9طא7!s9¢KFDو 03 K3 3 אوאi$D 03 77 ^ل3 U 5P و، a7! *jVI 4 אو3 03 KF Nא\^ل א א Y قHO א¤H$ אن01 L אhF وאض وאD1 وאh אi$D. U ªORم و$+\א .:3$DאوH''مאgO3אم$+א has-a اﻟﻌﻼﻗﺔ ﻣﻦ ﻧﻮع .8.5 JOאنאcQ'عNאאWS،O+\אhJOאY h. א53^'ع אN'אSאWg!NHאولدUNRsאوF :אKPTh `אJ!^ل3NsZ!'א،AIC J!nD' 159 C# class Tires { int TiresType; int TiresSize; } ﻛﻮد VB Class Tires Private TiresType As Integer Private TiresSize As Integer End Class ﻛﻮد אW، car has a tire iHא53z%gNP وtire is not a car iH'ع53hאH9אنאN7Qf : אKPTiH אJ!oQNNP> C# class Car { Tires carTires=new Tires(); } ﻛﻮد VB Class Car Private carTires As New Tires() End Class ﻛﻮد ﻣﻼﺣﻈﺔ وعمل خاصية لھا من اجل القراءة والكتابةprotected اوprivate ال تنس ان بامكانك تعريفھا كـ إليھا Casting اﻟﺘﺤﻮﻳﻼت .8.6 .سHدU:Dوא'א:'مאمgO\אv,،I 'ع53KQ'R'אSً3'FD Casting ل$V7Q ،Q( אدcast) אم$+אSKQ'R אو7Q1א، Classes אلnDSO\@אO1ولRNوאن : BMW iHoQNF.'ً ^3 160 C# BMW ahmedCar=new BMW(); ﻛﻮد VB Dim ahmedCar As New BMW() ﻛﻮد دאkHNF.'ًMQא،RRbiH'VKFf'! BMW ل7'م7 دאq\لאHNF.و RRb PאFאFN، Car 77LאUS BMW KنRRbאWS'نP! Car K7 :אiH'V BMW oQNF.'^א17Nא C# Car ahmedCar=new BMW(); ﻛﻮد VB Dim ahmedCar As Car = New BMW() ﻛﻮد i,3 q\ل אH א5P> وאن، implicit cast nD$Q 3 'S ! ً وRb 'عs'\א אWS . Car K7tאא$א :אKPT BMW oQ:! NF.Iً9^3ضZON C# Object ahmedCar=new BMW(); ﻛﻮد VB Dim ahmedCar As Object = New BMW() ﻛﻮد f'! Car K7tאא$ אq\لאHNF.'5P،ًMQ אObject 'S J!Kً نMQאRbאWS :لאP,9א$] cast KF'م7אW،1IHg( C# functionname((Car)ahmedCar); functionname((BMW)ahmedCar); ﻛﻮد 161 VB functionname(DirectCast(ahmedCar, Car)) functionname(DirectCast(ahmedCar, BMW)) ﻛﻮد is اﻟﻜﻠﻤﺔ اﻟﻤﺤﺠﻮزة .8.7 : ^ل3،^אf1א53'Sول9אf1ذאن אF!HIFPאlWS'م7 C# if (ahmedCar is BMW) { ﻛﻮد } VB If TypeOf ahmedCar Is BMW Then ﻛﻮد End If ذאF!fאن$Qو،JO@אO537T3א'عi$D53h אq3i$D'د% وUFPאlWS¤$O .ً ^3H אو! אBMW 'ع53 Visual Studio Class Diagram .8.8 :gD^ل3אWS، Class Diagram אلKFiאدא2005Hא$b9א53zא$'אQ`'אل'دO'!אQ 162 ، Q$ t אhאJOض אD אو، i,3 gD KF א53 و، new - class diagram 53 g!s אNP> . modeאאلWSUO+\אh. אzTאNP> Polymorphism اﻟـ .9 اﻵن ﺳﻨﺘﻌﺮف ﻋﻠﻴﻪ، ﺑﺸﻜﻞ ﻋﺎمpolymorphism ﺗﻌﺮﻓﻨﺎ ﻓﻲ درس ﺳﺎﺑﻖ ﻋﻠﻰ ﻣﻌﻨﻰ ال ... ﻼ ً ﺑﺼﻮرة أﻛﺜﺮ ﺗﻔﺼﻴ 5Pً'دوMQ'!אQ ، implementation ونא$ class oQFQWوאs\אoQא fQ 3 'S و، AI وאJO אY א$ אصimplementation אلq FQ K7\ אU .Overriding אنK.iH7\א\!אXrbאא א$'دא%وNsZ!'א،NאصiH^لא3ضZON .Z3'10KPً'%fV(ً ^3) iHوאنא،5QNא$ONQ C# public int calc(int fuel) { return fuel * 10; } ﻛﻮد 163 VB Public Function calc(ByVal fuel As Integer) As Integer ﻛﻮد Return fuel * 10 End Function 5KPً'%fVgذא،i$D7@אOnD 9iHאlWS אنNOT אBMW iHNFD$5Pو fQ 3'SאWS، 7T\ אJOאU calc א$אoQiدDא%r 5LאlWSU ،a7!hאZ3' א$ אoQ Q 5D ذQ . polymorphism د¨ אل3 $' אS وOverriding iد7 אiدD א :אKPT virtual 'ع53 base class אلU9א C# public virtual int calc(int fuel) { return fuel * 10; } ﻛﻮد VB Public Overridable Function calc(ByVal fuel As Integer) As Integer Return fuel * 10 End Function ﻛﻮد م$D5P>F، 7T\ אJOאUgOQiدDא5P>א$אlWS אنc overriddeable אوאلvirtual אل :7T\אJOאU'دאPאGPgOQiدD9 ،ًMQאgOQ C# public override int calc(int fuel) { return fuel * 5; } ﻛﻮد VB Public Overloads Overrides Function calc(ByVal fuel As Integer) As Integer Return fuel * 5 End Function ﻛﻮد 164 f،zN אhJOאU g4.53 وj אJOאUًH! implementation אل¤NP>ًMQC U:D fNW אinterface ' אلS وAbstract class implementation אل53غHO אJOא .3د.3 Abstract اﻟـ .10 ون$ QدD J! دg אN!D و، Abstract Class F nN3 nD N! س אH$ אU i א[`'زFPم א$+ ، :3א$+ אK. :N3 + KFD nD NO א4< P 5P ، implementation :אKPT:OQabstract C# abstract partial class Car { } ﻛﻮد VB MustInherit Partial Class Car ﻛﻮد End Class ﻣﻼﺣﻈﺔ C# فيabstract ھي مناظر كلمةvb.net فيMustInherit الكلمة المحجوزة :]1IoQאאWSN1Qf' LאlWSU C# Car ahmedCar=new Car(); ﻛﻮد VB Dim ahmedCar As Car=new Car() ﻛﻮد 165 Abstract method .10.1 JO אU k overriding KF 'م7 KP virtual وאل$ אoQ 'م7 N ً אMQس א אH$ אU ذ 234\אH%دאH'א5P،:S{אوg'دאصP אiدDאULאN1Q3אWSو،ً79 7T\א :אKPT Abstract method oQW'م7overridingiد7אiدDאnD C# public abstract int calc(int fuel); ﻛﻮد VB Public MustOverride Function calc(ByVal fuel As Integer) As Integer ﻛﻮد 166 167 اﻟﺒﺎب 9 اﻟﻮاﺟﻬﺎت Interfaces 168 169 Interface ﺗﻌﺮﻳﻒ ال .1 +KFD5P> abstract methods and membersnD'd abstract class 'S interface אل ^9 implement KFDP3FQ F، inheritance 53ً9$ implementation 'مgO}אم$+:N3 . multiple inheritance 'مgO3 5DKQ$'אSوi$א'אi\אU interface 53 :ً ^3אKPT interface oQ5P> C# public interface ICar { int carMaxSpeed{get;set;} void AddItem(string Item); } ﻛﻮد VB Public Interface ICar Property carMaxSpeed() As Integer Sub AddItem(ByVal Item As String) ﻛﻮد End Interface :ً ^3אKPTI53 interface ق7,אP3אنnN9 C# public interface ICar:IDisposable { int carMaxSpeed{get;set;} void AddItem(string Item); } ﻛﻮد VB Public Interface ICar Inherits IDisposable Property carMaxSpeed() As Integer Sub AddItem(ByVal Item As String) End Interface ﻛﻮد :'دאPאP 'م7 interface 9 implements KFو 170 C# public class BMW : Car { ﻛﻮد } public class BMW2 : Car, Truck { } VB Public Class BMW Implements Car ﻛﻮد End Class Public Class BMW2 Implements Car, Truck End Class .ً .WNF.FJOאمא$+א53و،i$Q$%!دوאلs א. i'د%'\وאلא$אiدDאNP>אن : ﻫﺬه ﺑﻌﺾ اﻟﻨﻘﺎط اﻟﺘﻲ ﻻ ﻳﻤﻜﻨﻚ ﻋﻤﻠﻬﺎ ﻣﻊ اﻟﻮاﺟﻬﺎت :JIFאlWSK^F!אW، :N3 Object אKFD5P> 9 Interface אل،Qא$ C# ICar x=new ICar(); ﻛﻮد VB Dim x As New ICar() ﻛﻮد :JI interface אلKIدאFאlWSK^3אW، interface אلUدD q3oQ5P>9 C# int number; ﻛﻮد 171 VB Dim number as integer ﻛﻮد :אKPT get وset bIKFD'S،KQ$א C# int x {set;get;} ﻛﻮد VB Private Property x() As Integer Get End Get Set End Set End Property ﻛﻮد . interface אلKI'د دא1CNP>901 . interface K constructor KFD5P>9F Name Clashes .2 :TU KT3E$d}Hو، interface 53^9 implements KF3 struct אوclass 'م7Q3 ً א :ضא\^لאZON،zא C# public interface ICar { void move(); } public interface ITruck { void move(); } public class BMW: ITruck, ICar { } ﻛﻮد 172 VB Public Interface ICar Sub move() End Interface Public Interface ITruck Sub move() End Interface Public Class BMW Implements ITruck Implements ICar End Class ﻛﻮد : BMW i$Q$אJOאU move א$ implementation KFF.'F!PT3${5}H C# public class BMW: ITruck, ICar { void move() { // do something. } } ﻛﻮد VB Public Class BMW Implements ITruck Implements ICar ﻛﻮد Private Sub move() ' do something. End Sub End Class 'م7، truck 53 move א$AI وאcar 53 move א$ implementation KFDhدHC'ذא35Pو :אKPTW 173 C# public class BMW: ITruck, ICar { void ICar.move() { // do something. } void ITruck.move() { // do something. } } ﻛﻮد VB Public Class BMW Implements ITruck Implements ICar Private Sub move() Implements ICar.move ' do something. End Sub Private Sub move() Implements ITruck.move ' do something. End Sub End Class ﻛﻮد :אKPTSzD$אQYא$א53i$א وא$Q$5P>، BMW JOא53 object KFD$و C# BMW ahmedCar=new BMW(); ICar temp= (ICar)ahmedCar; temp.move(); ﻛﻮد VB Dim ahmedCar As New BMW() Dim temp As ICar = DirectCast(ahmedCar, ICar) temp.move() ﻛﻮد 174 IEnumerable interface .3 'م7Q ClassوCJ!KFDO5D3د. وسHدE ^ضאنوN، interfaces אل03NوHאندKb'א 3 وIEnumerable nF\ אinterface XC$NسH$א אWSU،Y3 interface K implement KF .ذzאHوi'%\אi$jOאS ﻣﻼﺣﻈﺔ فھذا واحد من الدروس التي ستالحقنا كثيراً أثناء تطبيق، أرجو منك أن تركز جيداً في ھذا الدرس . Linq مبادئ : אKPThi$DnD 'zC!'OV3J!NQ$ضאنZON C# string[] users = { "Ahmed", "Mohammed" }; ﻛﻮد VB Dim users As String() = {"Ahmed", "Mohammed"} ﻛﻮد :ً 7NFFfor – eachאم$+'دאPمא$+N!'OV\אhQ')izא7وאن C# foreach (string us in users) { Console.WriteLine(us); } ﻛﻮد VB For Each us As String In users Console.WriteLine(us) Next ﻛﻮد ًD' א\^ل0' 'م7N ،bN ! אnD אنHو$ م دא$+ N א${ ، array nD $F N' אWS :אKPTYO&'\אJ!ضZON،J!nDدFD9 'نذP 175 C# public class employee { int emp_number; string emp_name; } ﻛﻮد VB Public Class employee Private emp_number As Integer Private emp_name As String End Class ﻛﻮد 53 D'F 5D iHD 'S م$+\ אن א، Y3$+\ אh nD 'd AIC J! NQ$ 5Pو :ً ^3אKPT YO&'\א C# public class users { employee[] emp = new employee[3]; users() { emp[0] = new employee(10, "Ahmed"); emp[1] = new employee(20, "Khaled"); emp[2] = new employee(30, "Ali"); } } ﻛﻮد VB Public Class users Private emp As employee() = New employee(2) {} Private Sub New() emp(0) = New employee(10, "Ahmed") emp(1) = New employee(20, "Khaled") emp(2) = New employee(30, "Ali") End Sub End Class ﻛﻮد :Bאم$+ًMQ אfor each אم$+ ً MQאYO&'\אאضאNNP> 176 C# foreach (employee e in emp) { } ﻛﻮد VB For Each e As employee In emp ﻛﻮد Next . IEnumerable אل03:nNWאC$\'אSאWS ،Y3VNDD loop K03 : IEnumerable nF\ אinterface K9אKPTא C# public interface IEnumerable { IEnumerator GetEnumerator(); } ﻛﻮد VB Public Interface IEnumerable Function GetEnumerator() As IEnumerator End Interface ﻛﻮد :אKPT IEnumerator 'ع53interfaceg%وאoQ 'م7Q،א\^لאUAFو C# public interface IEnumerator { bool MoveNext (); object Current { get;} void Reset (); } ﻛﻮد VB Public Interface IEnumerator Function MoveNext() As Boolean ReadOnly Property Current() As Object Sub Reset() End Interface ﻛﻮد 177 KF1MN، interfaceg% א'אlWk implements KF 'م7 users J!K< אنUGN'אW :אKPT'نذP، GetEnumerator() א$implement C# public class users:IEnumerable { employee[] emp = new employee[4]; users() { emp[0] emp[1] emp[2] emp[3] = = = = new new new new employee(10, employee(20, employee(30, employee(40, ﻛﻮد "Ahmed"); "Khaled"); "Ali"); "Sami"); } public IEnumerator GetEnumerator() { return emp.GetEnumerator(); } } VB Public Class users Implements IEnumerable Private emp As employee() = New employee(3) {} Private Sub New() ﻛﻮد emp(0) = New employee(10, "Ahmed") emp(1) = New employee(20, "Khaled") emp(2) = New employee(30, "Ali") emp(3) = New employee(40, "Sami") End Sub Public Function GetEnumerator() As IEnumerator Return emp.GetEnumerator() End Function End Class :אKPT ً MQًאQو$QWم7אNNP> 178 C# ﻛﻮد IEnumerator i = emp.GetEnumerator(); i.MoveNext(); employee myCar = (employee)i.Current; VB Dim i As IEnumerator = emp.GetEnumerator() i.MoveNext() Dim myCar As employee = DirectCast(i.Current, employee) ﻛﻮد ﻣﺎذا ﻧﺴﺘﻔﻴﺪ ﻣﻦ ﻫﺬه اﻟﻄﺮﻳﻘﺔ ؟ J!5D^ل3'SNSlد$V53ن،'g. א2NQאن01Qh א$D'א72343]!0.א'אU אم$+g!K7NوאgN3 izא7אنאND1bوא،hi$D7:,אhא53D'FnD' .moveNext : yield اﺳﺘﺨﺪام :'دאPאP.'دאPא53ً9$ C# public IEnumerator GetEnumerator() { yield return emp[0]; yield return emp[1]; yield return emp[2]; yield break; } ﻛﻮد KV n אWPS א^ !^^ و، אوF7 אiدDא א$ zD$ אول א03 وL אlWS U .yield break KOq9CnNeCYLذאnو، Linq KV3$NDOאh3א$+9 אSC53i$وאnDfN .g%א'אlWS 5DND 179 ICloneable interface .4 :'دאPאGP 3$NDNאnN}،5jP¢NאFDg$V7Q clone אلFD C# int x=5; int y=x; ﻛﻮد VB Dim x As Integer = 5 Dim y As Integer = x ﻛﻮد :אKPThJOא03N3U5Pو، y x F.K7N'م7ً! N¦! C# car x=new car("BMW"); car y = x; ﻛﻮد VB Dim x As New car("BMW") Dim y As car = x ﻛﻮد KQ$ א!¦نאWو، x F.:!WنאP\ אTQVQ y نK، y K7N9 x F.אن0.א'אU @P@P وאy F.ل$ x F.U .I אq\ אUgsووF7אUi$Q$%+KFDK%א53 clone אلFDNS53 'دNNP>،ضqאאWkg3א$+א5P>، clone א$אnD 't אICloneable g%א'א : C# public object Clone() { return new car(this.carName); } ﻛﻮد 180 VB Public Function Clone() As Object Return New car(Me.carName) End Function ﻛﻮد :אKPT clone אم$+i$Q$%+ KFDP3bאنא C# car x=new car("BMW"); car y=(car)x.Clone(); ﻛﻮد VB Dim x As New car("BMW") Dim y As car = DirectCast(x.Clone(), car) ﻛﻮد IComparable interface .5 א אلWS KP, 'نPQ אن1 א53 אW و، H7F interface א אلWS م$+Q ، 9 א53 s' وאS F : אKPTinterface C# public interface IComparable { int CompareTo(object o); } ﻛﻮد VB Public Interface IComparable Function CompareTo(ByVal o As Object) As Integer End Interface ﻛﻮد U 1F7א، אوU 07א\دאU$Sً!،F.HF.$א$ (אنא3 NP> .qbC אولf1'نאU1−و،4אولאf1'نא 181 17NאKIא$אgF. وhאHD9@نQو3'نPQYNjP]نא¤ WiدDא53Dدא9ً 53:NF.3אWSو.!H7\جNא،:% 53'Sو،iאWאUنP\@אONgH,אU . equals א$ لאI !3%U5K،9אم¤ذא5jPאאWSوQKS !\%rN!NSNQ$tא17Nא3א .gbאJOא5FsiHא0Nb¢QHضZON و،qbאوא4אFgQא 'אد9אGP، IcomparableJOא1NbאJOאK`N،سאH$אUNF.F :ً ^3 אKPTضאZON، CompareTo א$אU C# int IComparable.CompareTo(object obj) { Car temp = (Car)obj; if(this.year > temp.year) return 1; if(this.year < temp.year) return -1; else return 0; } ﻛﻮد VB Private Function CompareTo(ByVal obj As Object) As Integer Implements IComparable.CompareTo Dim temp As Car = DirectCast(obj, Car) If Me.year > temp.year Then Return 1 End If If Me.year < temp.year Then Return -1 Else Return 0 End If End Function ﻛﻮد א$א،'مgO\ אKgאWS5P،1و0و1−53ً9$94و0و100−iدDא01¤ WDدא9 ً 182 .אאWSF.gNQدونאنa7!4אcQ G%'3.HאووcQOb،qbאcQG.H9$KF .Oא : Sort اﻟﺪاﻟﺔ א3אPNF.'L אlWS U، myNumbers م.H9א53 array !'OV3NQ$ضאنZON :ً3'gO3'دPنאP C# Array.Sort(myNumbers); ﻛﻮد VB Array.Sort(myNumbers) ﻛﻮد .]1IE$R$]אWS !¦نgZ'دPאאWSNو،hאHא53!'OV3NQ$'ن5Pو אWSאم$+אNPFLאlWSO!، IComparable interface אل1 car JO'نאU5P 'نPQ}H،g4 אF.t אCompareTo دאnDًدאFDאH7\'م7f'g א$א ^ ًאوא3 check دא53ً9$א$ و'د אinterface אאلWS1'م7ً!ًאWS 2343g'sًوو79KPbאJOאمא$+אKg!s9ًאWS . Fg\@אONم7Iא I 183 اﻟﺒﺎب 10 اﻷﺧﻄﺎء واﻗﺘﻨﺎﺻﻬﺎ 184 185 5Pو،:! Iوz1I9אg,]وא1אKjH3 ،gQدOوgbN.אOوz1IאnDאWSNHدUfN :23אUKVtאz1Iم א.Cs'جنQא$אK. : اﻷﺧﻄﺎء اﻟﻨﺤﻮﻳﺔ- Syntax Errors .1 Visual אلK^3 Advanced Programming Environments U و، Kg9' אS z1I9 א53 'عNא אWS :אF]א1אאWS^ل3،ًQH'! z1IאlWSfTאQ،Studio , netbeens ... etc ﻛﻮد if x.Nome = somevalue Kg9 אSz1IאlWSK^3،i'د%'3 Nome b]نא¤4§WONאK.]1IH $`01 KjHRb אVisual Studio .net 2008 Uو،gDKFtא4אqJ لI53g!TאQو .7Q1 אlWgg'وgS O5P>وQqRsوא1א : اﻷﺧﻄﺎء اﻟﻤﻨﻄﻘﻴﺔLogical Errors .2 g(Q71N31I:NP]'و1I$%'Q 9}H'دPא$bn!،Gb' אSz1Iא53'عNאאWS :''دS]1אאWSnD^ل3aא،WON א$ND ﻛﻮد Byte x = 100000 ]1Ig(אWS5PQ_>$7אhאHא$b9אU5Pو،$LאאWS53qb אByte 'عNود א$אنfً .AFًQ''P3F אنא .א..: new KFD K. object لF.دN]א1אאWSnD^3א ًD א'א¤NS אنK ، i,3 g( z1I אlWS K^3 Rb א، i$Q$' אQ !`'אل 'دhאHא$b א03 5P . warningsKP,nDg!TאnDHد.'Q`'אل'دOאb אLogic Errors אل53Gbא :'אعאC Sאz1IאS وLogical Errors אل7C$N،ًא$GSW5 186 : User Error 5P،م$+\אFD5Q+:!'م7 Byte א\^لאلNsZ!'א،234אمא$+א532Nz1IC $. 5P _' F! KT\ אU G م$+\ א53 ]1א אWS ، f9 א10 .H لIم د. م$+\א جH$N:! IوFאIUVhلIًאدMQא،Y3$LFم{وز א$D53$]طא,Osא .م$+\אz1IC א : Exceptions iH'V gF Q _ ً ^3 i'د%'3 h i$D. אوo3 ! )و، z1I א53 g,'ع אNא ، nullable type אم$+ونא$ null وgאYUhאi$D.53h izא.)و،RRb .iH'gT\אz1Iא53:! Iو، ReadOnly Vo3P)وא : Bugs g3$+tوزא$NQ'א+g!} 23א4א0BU$%'و،S$D9وSV5P>9،ig,z1Iא^א izא. אوq3fWنGE$$.،ع1\אH$.gQدO ولNNPوgN323'5iאدU، 53٪99لg( 9$.z1IאlWS،א...H!F.gא5(5وiאWאUً bאi'د%'3 F.53 q3 23 א53 Q{ ¢ i$D ¤NS 'نP i אدU אW ، a7! $م وא$+\ g( NP وY3$+\א . א+Nאv K.gQ$وz1IאlWS^ل3א53!א3[و 53hאzN^Nא0sولوRNًMQ'عאولאNא،S'אSوz1Iא53^'عאN אnDNאWSNHدU `!^^אL א3א،אوLאUSאS7RאKB5Pمو$+\אhאHIא53$]אK%א .g7K^3א'אS\وאiF\א System.Exception اﻟﻔﺌﺔ .3 KQ]1IC!¦ن0.א'אU،(مNאUE$tאz1I א03K3 .net _D U V+\ אJOאS 1אאWS03K3 System.Exception 'لlHو$Wوא، CLR אل:H (مN'مא7Q(مN :אKPTJOאlWShQ') ، 187 C# public class Exception : ISerializable, _Exception { // Public constructors public Exception(string message, Exception innerException); public Exception(string message); public Exception(); // Methods public virtual Exception GetBaseException(); public virtual void GetObjectData(SerializationInfo info, StreamingContext context); // Properties public virtual IDictionary Data { get; } public virtual string HelpLink { get; set; } public System.Exception InnerException { get; } public virtual string Message { get; } public virtual string Source { get; set; } public virtual string StackTrace { get; } public MethodBase TargetSite { get; } } ﻛﻮد ﻛﻮد VB Public Class Exception Implements ISerializable Inherits _Exception ' Public constructors Public Sub New(ByVal message As String, ByVal innerException As Exception) End Sub Public Sub New(ByVal message As String) End Sub Public Sub New() End Sub ' Methods Public Overridable Function GetBaseException() As Exception End Function Public Overridable Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext) End Sub ' Properties Public Overridable ReadOnly Property Data() As IDictionary Get End Get End Property Public Overridable Property HelpLink() As String Get 188 End Get Set End Set End Property Public ReadOnly Property InnerException() As System.Exception Get End Get End Property Public Overridable ReadOnly Property Message() As String Get End Get End Property Public Overridable Property Source() As String Get End Get Set End Set End Property Public Overridable ReadOnly Property StackTrace() As String Get End Get End Property Public ReadOnly Property TargetSite() As MethodBase Get End Get End Property End Class :JOאlWk9ق א1*وאjVאnDfولאRN nN\א bא bL] א1אH Message ]1אאWk throw KFم.Wא9אo3 Source :N3iدO9א01،KVOאPT\אvTQ aאHnDbאlWS' HelpLink 3(N IT אلU*V+\مא$+\ א:N3$OQ}Hو234F 189 Throw Exceptions - رﻣﻲ اﻻﺳﺘﺜﻨﺎءات .4 O N.Y3o3'د%مو$DK^33]1 throw KF234'م א7Qאن5P>234 ¤WON لI ضאZON،]1+ throw KFg!אGAIC¤NSK(5P،:3K3]وא1אאWSizא. o\'د א%م و$D U ]1I H 'م ض7 53 وo\'د א%م و$D 53 $] check KF 'م7 :ً ^3אKPT C# if (!System.IO.File.Exists("c:\\ahmed.txt")) { Console.WriteLine("there is no file"); } ﻛﻮد VB If Not System.IO.File.Exists("c:\ahmed.txt") Then Console.WriteLine("there is no file") End If ﻛﻮد !s9،i$'3z1I*אN.iH'bUGو،a7!izא7o\] 'نא1IصN.7_}HNP AIC hאHDو אC ، GQ' א03 ^ i3 وWindows Forms אل5Fs JO@ אO אم$+9 ج$. KFD5P>hאHD9 אlWS53. g3א$+ אJ!234N'ً ^3234F throw KFDUG :אKPT]1throw C# ﻛﻮد if (!System.IO.File.Exists("c:\\ahmed.txt")) { throw new Exception("there is no file"); } VB If Not System.IO.File.Exists("c:\ahmed.txt") Then Throw New Exception("there is no file") End If ﻛﻮد 190 K3]وא1א5jizא.ً7901،gRsאوt]א1IHg&م. 'Q`'אل'دOאنא${אWPS .`'אلOא53ًj72NQW]א1א03K3F:3 catching exceptions - اﻗﺘﻨﺎص اﻷﺧﻄﺎء .5 'د%وU¤'א53234جאr Try אم$+S7Q aא،z1IصאN.אHدوz%אن :ً ^3אKPT،234אo.'UGQ ]دونאن1א C# try { x+=100; console.writeLine("no errror"); } catch { console.writeLine("some error!"); } ﻛﻮد VB Try x += 100 console.writeLine("no errror") Catch console.writeLine("some error!") End Try ﻛﻮد 234אKbאذ'א$DF!، catchل79אi,3! 7א0FאFDU]1I'د%وU .234אf7QאQ5ن9אKUو، gDHدونא\و 7*אjVאمא$+E$W]א1א5DKbOضDًMQ אNNP> C# try ﻛﻮد { x += 100; console.writeLine("no errror"); } 191 catch (Exception e) { Console.WriteLine("Method: {0}", e.TargetSite); Console.WriteLine("Message: {0}", e.Message); Console.WriteLine("Source: {0}", e.Source); } VB Try x += 100 console.writeLine("no errror") Catch e As Exception Console.WriteLine("Method: {0}", e.TargetSite) Console.WriteLine("Message: {0}", e.Message) Console.WriteLine("Source: {0}", e.Source) End Try ﻛﻮد ضא\^لZON،אذ$DF!ضאDوSHIאNNPF! ،E$אن5P>tאz1IאfN' مD]1xHg(Nאذ$DF!و، overflow G'نPQאن5P>]1نאCf N'Uא C# try ﻛﻮد { x += 100; console.writeLine("no errror"); } catch (OverflowException e0) { Console.WriteLine("value of x more than up bound"); } catch (Exception e) { Console.WriteLine("Method: {0}", e.TargetSite); Console.WriteLine("Message: {0}", e.Message); Console.WriteLine("Source: {0}", e.Source); } VB Try x += 100 console.writeLine("no errror") Catch e0 As OverflowException ﻛﻮد 192 Console.WriteLine("value of x more than up bound") Catch e As Exception Console.WriteLine("Method: {0}", e.TargetSite) Console.WriteLine("Message: {0}", e.Message) Console.WriteLine("Source: {0}", e.Source) End Try Finally اﺳﺘﺨﺪام .5.1 UGN'ً ^F!،:3$D]אو1I'د%وUSWONQ وtry - catch ¤'אQg$WONم$+ :'دאPאGP:3$D53 x q\אU]1IEو$5D(Nאq 3*D C# try ﻛﻮد { x += 100; console.writeLine("no errror"); } catch (Exception e) { Console.WriteLine("Method: {0}", e.TargetSite); Console.WriteLine("Message: {0}", e.Message); Console.WriteLine("Source: {0}", e.Source); } finally { Console.WriteLine("somehing"); } VB Try x += 100 console.writeLine("no errror") Catch e As Exception Console.WriteLine("Method: {0}", e.TargetSite) Console.WriteLine("Message: {0}", e.Message) Console.WriteLine("Source: {0}", e.Source) Finally Console.WriteLine("somehing") End Try ﻛﻮد 193 break اﺳﺘﺨﺪام .5.2 .`'אلON Exit Try وC break אم$+ א5P>،33UzN^N9א53وج+ Target Site اﺳﺘﺨﺪام .5.3 UgN3iدO9א5P>،]1+throw KF3.tאא$ وאJO'لאi$Q$Dh3'3bאlWS!' .]1אEو$نP3!\ Debug KFD HelpLink اﺳﺘﺨﺪام .5.4 ً ^3אKPT:N3iدO9א:NP>Y3N0sوQ5D، gم$+\وאCJOمא$+3iא!د01 C# try { m += 100; Console.WriteLine("no errror"); } catch (Exception e) { e.HelpLink = "www.ahmedgamal-space.blogspot.com"; } ﻛﻮد VB Try m += 100 Console.WriteLine("no errror") Catch e As Exception e.HelpLink = "www.ahmedgamal-space.blogspot.com" End Try ﻛﻮد 194 ﻋﻤﻞ أﺧﻄﺎء ﺧﺎﺻﺔ .6 BaseExceptionJOא53g.7,אQאUً79g3א$+אNP>]1I'عNא53J!oQNP> remote אلU g3א$+ אP3 אK% א53 Iserializable g% א'א53 7T3 g ً MQC جC F :ً ^3אKPTصI]1IoQNP>،:! Iو C# public class NewException : BaseException, ISerializable { public NewException() { // something here } public NewException(string message) { // something here } public NewException(string message, Exception inner) { // something here. } // אلF Sterilization ﻛﻮد protected NewException(SerializationInfo info, StreamingContext context) { // Add something here. } } VB Public Class NewException Inherits BaseException Implements ISerializable Public Sub New() ' Add something here. End Sub Public Sub New(ByVal message As String) ' Add something here. End Sub Public Sub New(ByVal message As String, ByVal inner As Exception) ' Add something here. ﻛﻮد 195 End Sub ' אلF Sterilization Protected Sub New(ByVal StreamingContext) ' Add something here. End Sub End Class info As SerializationInfo, ByVal context As :msdn'ع%אNP>gbN.وאz1I9'لא$QF رابط http://msdn.microsoft.com/en-us/library/ms229014(VS.80).aspx 196 197 اﻟﺒﺎب 11 اﻟﺘﺠﻤﻴﻌﺎت Collections 198 199 ذאلK%C53،bNDi$DnD'd container KF]`3iدDO+\א4אN71U ج$!Nא9.OhJ!53nً אI'صوאVNموא.H9 א53 array KFDNP3אنNQCH وarray U، O+\ אcollectionsאلh$%אوWSK%א53، array אلNS!'tא53^9م אg\א .אz,نgDff'אWSNHد System.Collections ﻓﻲinterfaces اﻟـ .1 :אhg%א'א$%' collection אلUi'د%'\ אhg%א'אN%אH' : Icollection אمKPTאk،:! I وIsSynchronized وאلsize אلK^39طא7NאnDg%א'אlWS' :א C# public interface ICollection : IEnumerable { int Count { get; } bool IsSynchronized { get; } object SyncRoot { get; } void CopyTo(Array array, int index); } ﻛﻮد VB Public Interface ICollection Inherits IEnumerable ReadOnly Property Count() As Integer ReadOnly Property IsSynchronized() As Boolean ReadOnly Property SyncRoot() As Object Sub CopyTo(ByVal array As Array, ByVal index As Integer) End Interface ﻛﻮد 200 : Icomparer .7gDN! : Idictionary gNQوNDوYO&'\אhً ^3 5Q+g3א$+א5P>،د9אK%א53gא53s'وאSFم$+ .:! IوfWL!وאs دوאلnD'،:'אND אو:א9$*+TאnDذ$H'^א5P>r :אKPTkאمKPTא C# public interface IDictionary : ICollection, IEnumerable { bool IsFixedSize { get; } bool IsReadOnly { get; } object this[object key] { get; set; } ICollection Keys { get; } ICollection Values { get; } void Add(object key, object value); void Clear(); bool Contains(object key); IDictionaryEnumerator GetEnumerator(); void Remove(object key); } ﻛﻮد VB Public Interface IDictionary Inherits ICollection Inherits IEnumerable ReadOnly Property IsFixedSize() As Boolean ReadOnly Property IsReadOnly() As Boolean Default Property Item(ByVal key As Object) As Object Get End Get Set End Set End Property ReadOnly Property Keys() As ICollection ReadOnly Property Values() As ICollection ﻛﻮد 201 Sub Add(ByVal key As Object, ByVal value As Object) Sub Clear() Function Contains(ByVal key As Object) As Boolean Function GetEnumerator() As IDictionaryEnumerator Sub Remove(ByVal key As Object) End Interface : Ienumerable .ً7g, : Ienumerator .ً7g, : IdictionaryEnumerator ،א$אlWg אصinterface'אلSאWS، GetEnumerator א$א$` IDictionary U(9' :אمאKPTאk C# public interface IDictionaryEnumerator : IEnumerator { DictionaryEntry Entry { get; } object Key { get; } object Value { get; } } ﻛﻮد VB Public Interface IDictionaryEnumerator Inherits IEnumerator ReadOnly Property Entry() As DictionaryEntry ReadOnly Property Key() As Object ReadOnly Property Value() As Object End Interface ﻛﻮد 202 : IhashCodeProvider . GetHashCodeא$אمא$+Y\ אcollection K hash code אلiدD* : Ilist KPTא:! I وfWLوאR!وאs g3K3אKgدوאلi$DnD'،3אU3KאWS ،Fj. :אKPTkאم C# public interface IList : ICollection, IEnumerable { bool IsFixedSize { get; } bool IsReadOnly { get; } object this[ int index ] { get; set; } int Add(object value); void Clear(); bool Contains(object value); int IndexOf(object value); void Insert(int index, object value); void Remove(object value); void RemoveAt(int index); } ﻛﻮد VB Public Interface IList Inherits ICollection Inherits IEnumerable ReadOnly Property IsFixedSize() As Boolean ReadOnly Property IsReadOnly() As Boolean Default Property Item(ByVal index As Integer) As Object Get End Get Set End Set End Property Function Add(ByVal value As Object) As Integer Sub Clear() Function Contains(ByVal value As Object) As Boolean Function IndexOf(ByVal value As Object) As Integer ﻛﻮد 203 Sub Insert(ByVal index As Integer, ByVal value As Object) Sub Remove(ByVal value As Object) Sub RemoveAt(ByVal index As Integer) End Interface System.Collections اﻟﻔﺌﺎت ﻓﻲ .2 :אhJOאnD'd ArrayList Hashtable Queue SortedList Stack ArrayList • • • • • .2.1 !sא،hi$gNQ§ 53 array אلh@ONF،9א53s'وאSF array Fj.S .!'OV\אlWSbNDKIدא:! IوfWLوאGZوאKQ$! وאs9אhFDKgtאFj7אhאF\ אم$+gN3!'OV3fN،gQ'د3 وiHאאnD'tوא7(אiH)J!NQ$ضאنZON :א3א C# Car[] carArray = new Car[4]; ﻛﻮد VB Dim carArray As Car() = New Car(3) ﻛﻮد gN3i$وאfWrG}H،نV7N אوiدQ}جH،a7!hאH0H9אجf5P_}H ،*jVאlWS03K3אKghאHא53 ^P אarray אلN!'9AFP!،א...oVN\א53 .:! IوfWR 3جאوאR 204 oQ 'S D 3 K ، hF אlWS 'صVx KT3 אS 5D 7 array List hz% 5P K3 אnD ًאHد. 'نP System.Collection لusing KF 'م7 نC $ – א7Q1 arrayList .− ً 79g3,\א C# using System.Collections; ArrayList carList = new ArrayList(); ﻛﻮد VB Imports System.Collections Dim carList As New ArrayList() ﻛﻮد :iH!sאNP>وאن C# Car temp = new Car("BMW", 1990); carList.Add(temp); ﻛﻮد VB Dim temp As New Car("BMW", 1990) carList.Add(temp) ﻛﻮد :'دאPאGP^نאP\אUً ^3iH!אs9،Y3z%U insert KFDًMQא01 C# ﻛﻮد carList.Insert(3,temp); VB ﻛﻮد carList.Insert(3,temp) ::.'39$Y3VND3وC،Fj7אK3301ً MQC C# carList.Clear(); carList.RemoveAt(4); ﻛﻮد 205 VB carList.Clear() carList.RemoveAt(4) ﻛﻮد ::OVNא9$nوC C# carList.Remove(temp); ﻛﻮد VB carList.Remove(temp) ﻛﻮد :ً ^3אKPTًB gDאنHو$وא،د$ \!אCount bאمא$+אNNP> C# ﻛﻮد for (int i = 0; i < carList.Count; i++) { temp = (Car)carList[i]; } VB For i As Integer = 0 To carList.Count - 1 temp = DirectCast(carList(i), Car) Next ﻛﻮد אم$+QدD array gQ'NNP>،ً7NFF sort K^3AI* אjVאمא$+אNNP> ،א7Q1R م$+ indexof א$א،Fj7אG@P Reverse א$א، toarray א$א :אKPT'نذP،i'د%'\אhאH א5FsgNDRאUG وtemp iHאNQ$ضZON C# int find=carList.IndexOf(temp, 0); ﻛﻮد VB Dim find As Integer = carList.IndexOf(temp, 0) ﻛﻮد 17$Q$NP>F،$QF:3 K3وאVNنאP3'لb' find q\אمא$+א01אWPSو .ً bאg3א$+م א$DאوS qدאو$F0RאQא$ 206 .2.2 Hash Table _ذא،1\אhא5DR אKg9א:Fg3، data structure hא5Q§ق53$وא :NSQ$PQ لوI53gDfRV! K.53 hash table אلlWSDh3$.5P رابط http://en.wikipedia.org/wiki/Hash_table IndexesKj9$א53g3نkeysO\א53D'F5DiHDShashtable~!نא،$Q$,HVIو .9אvO\א031\א7א.نP3 T Linked list X :! VND K aQ Linked List 5D iHD hashtable אل5Q'P 'م7 N אU 0sوUz$ وאHashtable oQNPF! אن3C،O+\א:אzא%وא:دوאKF'م7Nو،AIא سH$אUlNF:! I وRemove وAdd,AddRange Q$7 א3אمאوא$+i,3:!hא .א Queue .2.3 3 Queue אنאلs'53]س9 5PhBZא£א9א03و،H'1אU:!LאBZא ولC ،Dequeue אم$+ g%אI وאEnqueue אم$+ : h א0! دQ ، ً ! H' 9 'S .77H'5DE$RNS 5RN!Y%H'אولאSYIא$א ً9'ل אوb'9א3H'UgMאن1א5F!،z Fאh7 23234Nذא 207 hFg\אGQ ) ©\)אH'و4'אS Queue ^אل3אg,}אHو،ًMQאhא !אU، h\(אU:@אN95P،iH'baًאWON 'אولSH'1ً9'bאولو،©\אkIאد 9 slides (مאلN!sאQ'و9אK^3h'لאIدUPRtאbN א53$Q$א¤NS^Q$Lא .א...i$وאi3 taskאلWONQ :אKPTz FאH'ضZON،ً^ א$ אن$Q9 C# Queue empQueue = new Queue(); employee temp=new employee(); for (int i = 0; i < 10; i++) { temp.userName = Console.ReadLine(); empQueue.Enqueue(temp); } ﻛﻮد VB Dim empQueue As New Queue() Dim temp As New employee() For i As Integer = 0 To 9 temp.userName = Console.ReadLine() empQueue.Enqueue(temp) Next ﻛﻮد @N9ً.ً%وIkوC'نPً9'IدYO&'\אنאولא$`، Dequeue KFN Loop KFאنNF.' .سאH$אUSN,tא:! I وCountK^3*jVאمא$+אP3 نC א$א3C،H'1א53i,3:!Wr'م7אولوVNא$ Dequeue א$אنאa7! ,אQgNאK. .نFH'1אU:ªOgNPوGZאUVND אول$g!Peek Queue אل1 O وData Structure H د$. N ' W א5&C ، JO אlWS 1 03 JOאlWS03ًא$DV!אنWN3:O2D5 ^P وאcircular queue وאل، linked list ~אمא$+ 208 Stack .2.4 U IאVNאنא، LIFO - Last Input First Output N70Q:אא$DF! Queue אلK^3 Peek אل، pop אم$+g%אIאQ وPush אم$+bNلאIאدQ،אوجU'אولS'لI$א . Stack אل53 :!W دون9 ً 'I دI אN U 'S אول وVNض אD U S F gFg} 'م7 :אKPTQ Stack אلoQ C# Stack jobStack = new Stack(); ﻛﻮد VB Dim jobStack As New Stack() ﻛﻮد : اﻻﺳﺘﺨﺪاﻣﺎت ،ذnD$F3'אNh71(3ذאن، Queue אلK%א53h3א$+ אH'VKgQ NU:71zTًאQ 'نP}Hא$UN\אj$} Stack אل5P،ً9مאو$ً9وCKbא'א .'3'Pאh71nDi אدUV7Q Stack אمאل$+א!¦نאW،77Lא :نא\د،H'و4אUh9א\دK'S Stack Kאم$+אaC A + B : אKPTH'و4אKI$ AB+ Q5SWONאنSWON stack UkIאدQH'و4אUو، postfix X'9אאWSnFQ .ً MQ אCompilers אلBUI^ل3،'لb'אGZ ^^ א.O אU P א0QHT3 $ ن אinfix وpostfix Y KQ'R אO s'Q 23 h7!\ אU HI .،SWON وstack Ugs'H'و4'مא7QOوKQ'RאO234 אs'Q،ND'F¡ FgNF!HI9אNP>'ز و3مאوא.H9אمא$+KLאNP>،h'א1ضאDDאض9 View .KbOًאFg3NאذאWS.iW!NאnDא53 رابط http://vb4arab.com/vb/uploaded/3/21207604046.rar 209 :0.'\אאWS53i,3KQ'RאFD2nDא عNP>وC رابط http://scriptasylum.com/tutorials/infix_postfix/infix_postfix.html :NS MSDN 0.'3US${KbOא53$Q3 رابط http://msdn2.microsoft.com/en-us/library/aa289149(VS.71).aspx Nذא17NאlWS53 ق19אNP>، Data Structure D1NQسH$אאWSU3K nD ً 13 'نP אن¤$O ، \D U ^ ًא3 KIא$Q Wא א_ אWS 5D ^P! א3 U G . Algorithms !אلsא:א 537T3ًVV§^ אAIאhJ!nD'dوSystem.Collections.Specialized fQ3¤NSًMQC .7אhJOא 210 211 اﻟﺒﺎب 12 اﻟﺒﺮﻣﺠﺔ اﻟﻤﺘﻘﺪﻣﺔ ﻓﻲ .net 212 213 .net 200803i3ولg&Wא$Q$אgN3 .netU4אbNDnDff'KVOאאWSU .XאאWSUQ'gF`NF.אW،3ًD'3$73gNP ًو.i'د%'3bNDgN3وa7! Generic .1 generics אلS، .net framework 2.003i$Q$אhאH'1א53i$وא03سH$אאWSUKb'א :אKPTD13ً9^3 ضZON، overloading 'مאلgO\ًא$Q$%ًא$1 C# public static void print(int x) { Console.WriteLine("Print As Integer {0}", x); } public static void print(long x) { Console.WriteLine("Print As Long {0}", x); } public static void print(string x) { Console.WriteLine("Print As String {0}",x); } ﻛﻮد VB Public Shared Sub print(ByVal x As Integer) Console.WriteLine("Print As Integer {0}", x) End Sub Public Shared Sub print(ByVal x As Long) Console.WriteLine("Print As Long {0}", x) End Sub Public Shared Sub print(ByVal x As String) Console.WriteLine("Print As String {0}", x) End Sub ﻛﻮد U01א${אWPSو،OhאZ3Hل799@אONدوאلE KFم.s'وאSF'دPא $S,وO א'אعD1hFDi$DX%،'صVN אوlongs Kمאو.H D1אא$אzD$'د אPא :א3א\^لאوאKnD،D1אB 214 C# print("Ahmed"); print(12); print(1000000000000); ﻛﻮد VB print("Ahmed") print(12) print(1000000000000) ﻛﻮد :אKPTD1א2'نP K،h אq\א53ًN3ًD'K79دאoQאنP3 אن،ًD''مgO\ אq Generics אل אKPT7 אE ^وאلא$אضאZ!א01$.אW،س9אאWSnD:3K3< وT> K7 S C# public static void print<T>(T x) { Console.WriteLine("Print As {0}: {1}",typeof(T), x); ﻛﻮد } VB Public Shared Sub print(Of T)(ByVal x As T) Console.WriteLine("Print As {0}: {1}", GetType(T), x) End Sub ﻛﻮد 215 :2N'نאPQf'،@ א\^لאONN71Uوאن Structure and Class Generics .1.1 Structs وאلClasses ً אلMQ א، Generics אل1 t אmethods אلnD N! س אH$ אU nD1NQ class אلnD1NQ3 وclass ^لאل3ضZON،gh'م אgO\אאWS1gNP> . struct אل Sو9אnD'عאولN'אd0jMא53YD'NQ$ وאن،0jMאnD ' J!ضZON ،'دH אnD'iS%AIC0jMאوאد(و¹א53)א'عK[ אUgNV Qtא0jMא .AIC0jMU.H و0jMאUאnD'd$. Identify K7אن2N7Q1אlWg N3אذא$Q$R71N3F.0sوfא(و5CUوC، ºVON3 YJ!'د% و4ن$7אKLא lWSU، 'مgO\אאWS q Generics אل035P، numbner אلK7 אمname אلK7م$+ :אKPTJOאVLא C# public class product<T> { private T Identify; public product(T val) { ﻛﻮد 216 Identify = val; Console.WriteLine(Identify); } } VB Public Class product(Of T) Private Identify As T ﻛﻮد Public Sub New(ByVal val As T) Identify = val Console.WriteLine(Identify) End Sub End Class :אKPT 'عאولNא535joQcNP>وאن C# product<int> prd = new product<int>(1001); ﻛﻮد VB Dim prd As New product(Of Integer)(1001) ﻛﻮد :אKPT^'عאN א53وC C# product<string> prd2 = new product<string>("Some Product"); ﻛﻮد VB Dim prd2 As New product(Of String)("Some Product") ﻛﻮد Generic Collection .1.2 Generic KFD nD אنHو$ אb א، Generic Class KFD NP3 س א אنH$ אU N! F NFF، Add,Delete ... etc K^3hFDi$'م7Q وhJ! i$D K7 J! KF'م7N، Collection :3 Collection nD^ل3אWS ،ً7 217 C# public class MyCollection<T> { private List<T> myList = new List<T>(); public T GetItem(int pos) { return myList[pos]; } public void AddItem(T it) { myList.Add(c); } public void ClearCars() { myList.Clear(); } } ﻛﻮد VB Public Class MyCollection(Of T) Private myList As New List(Of T)() Public Function GetItem(ByVal pos As Integer) As T Return myList(pos) End Function Public Sub AddItem(ByVal it As T) myList.Add(c) End Sub Public Sub ClearCars() myList.Clear() End Sub End Class ﻛﻮد nFQ3אWS،:! IوRً bאi!'3 q*אjV}אH*وjV א53 ^P!אsאP3ً Q אدColelctions ل אل$ :D دFD9 א79 Kא3 U 5P> Generic Collection ~ : ً ^3 אKPT،hאHא53 ذEmployee .... אوCar K7Qאن5P> C# MyCollection<Car> myCars = new MyCollection<Car>(); myCars.AddItem(temp); MyCollection<Employee> myCars = new MyCollection<Employee>(); myCars.AddItem(tempEmployee); ﻛﻮد 218 VB Dim myCars As New MyCollection(Of Car)() myCars.AddItem(temp) Dim myCars As New MyCollection(Of Employee)() myCars.AddItem(tempEmployee) ﻛﻮد :م.H אnوC C# MyCollection<int> myCars = new MyCollection<int>(); myCars.AddItem(12); ﻛﻮد VB Dim myCars As New MyCollection(Of Integer)() myCars.AddItem(12) ﻛﻮد .name K^3 *jVI nD 'd N אصGeneric Collection 'ن אلP PT3 N hg& NS t وאWhere iא[`'زFP אNhz%NS53،ً ^3م.H אوhJOאKPً ^3!'Q93אWSو،gs .دم7سאH$אUgNDE$RN Where T اﺳﺘﺨﺪام .1.3 $]وطTא0sوNNP>،hJOאA'K79 אنGeneric Collection אلKFDUطTאאWSNQ :قא1א nN\א طTא ValueTpe 'عNא53 h אq3A'K7Q9r where T : struct RefernceType'عNא53A' K7Q9 where T : class Constructor nD'dאن$9 where T : new() interface 1QאوY3 class 53T3'نPQ אن$9 where T : classname where T : Iinterfacename .Y3 :Q'א\^لאAN،gM03وط,i$D23دNNP>7Q1אlWg 219 C# public class Example <T> where T : class, IComparable, new() ﻛﻮد VB Public Class Example(Of T As {Class, IComparable, New}) ﻛﻮد . Constructor nD' وIComparable g%א'א1، reference 'نPאن$9 T אنcQאWS :ًא\^لאMQC C# public class Example<K, T> where K : class, new() where T : IComparable<T> ﻛﻮد VB Public Class Example(Of K As {Class, New}, T As IComparable(Of T)) ﻛﻮد IComparable g%א'א1 אن$9 T F! constructor k وRefernce 'نPאن$9 K אنcQאWS .0F`'O3g%53ً9$ T UzTאPRאP3 bא،وאن Delegates .2 . Delegatesאل03i\אlWS$D'3 ، advanced .net programming אل03NHKb'א .g3א$+'م7 \ذאvT'م7N،g3K3אOوgvTאنK. :אKPT אnDSو،KQ'RאhFbIًMQ אint $ وint K7دوאلi$DضZON C# public int ConvertEGToD(int EG) { return EG * 5.45; } public int ConvertRSToD(int RS) { ﻛﻮد 220 return RS * 3.75; } public int ConvertEGToRS(int EG) { return EG * 1.45; } public int ConvertDToRS(int D) { return D * 3.75; } public int ConvertDToEG(int D) { return D / 5.45; } public int ConvertRSToEG(int RS) { return RS / 1.45; } VB Public Function ConvertEGToD(ByVal EG As Integer) As Integer Return EG * 5.45 End Function Public Function ConvertRSToD(ByVal RS As Integer) As Integer Return RS * 3.75 End Function ﻛﻮد Public Function ConvertEGToRS(ByVal EG As Integer) As Integer Return EG * 1.45 End Function Public Function ConvertDToRS(ByVal D As Integer) As Integer Return D * 3.75 End Function Public Function ConvertDToEG(ByVal D As Integer) As Integer Return D / 5.45 End Function Public Function ConvertRSToEG(ByVal RS As Integer) As Integer Return RS / 1.45 End Function 221 لQ وאV\ אN א، h FD E Y O+\ אh Q'R م$+ دوאلi$D g! ، ً ! (9 F .PQ3אH9و$א'دوא دوאل03ً ^3ذKFD015NNP،KQ'Rא.HK^> q3لHوאi$ دאوאUgFDNNP>ً .s'אא\^لWg!אW،Oو4א א دא$Q$R switch אوif ط, B م$+ 53 و، م$+\ א53 h אC7N N U אن :X'P\'دאPV אWS،ghلאH'م7N C# if (Operation == 0) result = ConvertDToEG(userInput); else if(Operation == 1) result = ConvertRSToD(userInput); ﻛﻮد VB If Operation = 0 Then ﻛﻮد result = ConvertDToEG(userInput) ElseIf Operation = 1 Then result = ConvertRSToD(userInput) End If אWS،ً79SWONNم$+F gsDوSWONدونF!'عא3אن 'دa7!NضאZON5Pو U3O9CًMQא،FאWONi3مو$+\אnD ضi3،Y3HI9אhאW'م7NNאcQ ذאOperation אل.A'ªO93د3و،YOYP3UY3FאWON ج$.א .AICi3طTאKBKF1M . Delegatesאلh$%אوWSK%C53 Delegates ﺗﻌﺮﻳﻒ ال .2.1 hאZ3Hدא$D@O53وאل$ אlWS'نPאن:ج3אول،دوאلD'F¡ Delegates oQدH'א :אKPTNوא$ אصDelegate 'نאلPאW، output وאلinput @אلOkًMQC 222 C# public delegate int myDelegate(int value); ﻛﻮد VB Public Delegate Function myDelegate(ByVal value As Integer) As Integer ﻛﻮد אW ،gNDولp\אא$ א−BZ אRb ن−Q'OאאWkد$אنאTאBUD3Kوאن אKPTiV+\אNو,'نP C# if (Operation == 0) { myDelegate aDelegate = new myDelegate(ConvertDToEG); result = aDelegate(userInput); } else if (Operation == 1) { myDelegate aDelegate = new myDelegate(ConvertRSToD); result = aDelegate(userInput); } ﻛﻮد VB If Operation = 0 Then Dim aDelegate As New myDelegate(ConvertDToEG) result = aDelegate(userInput) ElseIf Operation = 1 Then Dim aDelegate As New myDelegate(ConvertRSToD) result = aDelegate(userInput) End If ﻛﻮد ، AIC i3 g3א$+אHאP אو، QgN Delegate אلWON 'م7Q W אIط אT אI] P3 MQא 'دPאNP>אW، אنF אlWSWON*§אدאfRbא$. aDelegate אنאل :אKPT C# if (Operation == 0) { myDelegate aDelegate = new myDelegate(ConvertDToEG); ﻛﻮد 223 } else if (Operation == 1) { myDelegate aDelegate = new myDelegate(ConvertRSToD); } // NS3אوאWO result = aDelegate(userInput); VB If Operation = 0 Then Dim aDelegate As New myDelegate(ConvertDToEG) ElseIf Operation = 1 Then Dim aDelegate As New myDelegate(ConvertRSToD) End If ‘NS3אوאWO ﻛﻮد result = aDelegate(userInput) $]א$C537دونאن133وאCCWON53gNnא$אzD$ אI]NP>،אWPSو .i$وאlWS،AICi3 KFאUً^ א$OQאWS،WONS% DelegateאلiدDوאVON3دאU$]אKFDNP>^وא .hD'FKP,nD Events اﻷﺣﺪاث .2.2 (א...אم$bאE)دiH9وC( א... ض3)$NDo&'3Y3E$KF'م7אنאنN%' وذא،:E$Lbאא$אQF'م7و،ً ^3 Event DelegatesQ5Dً7W'م7N SWONtאEא$9 ListKFD01!א3nDHد.]! Delegates אلU'$.N . Delegate אאلWSnD ... Event iא[`'زFPאQ5Di$Q$% 7Q13אNאن *K7QDelegateKF ً ^3iHKVtאEא$!א5Dولp3 Delegate Qא$ אUfN :'1\אא 224 C# public delegate void CarEventHandler(string msg); ﻛﻮد VB Public Delegate Sub CarEventHandler(ByVal msg As String) ﻛﻮد :Eא$9אoQ'م7Nوאن C# public event CarEventHandler Exploded; public event CarEventHandler Damaged; ﻛﻮد VB Public Event Exploded As CarEventHandler Public Event Damaged As CarEventHandler ﻛﻮد :אKPTg!E$אWON'دP لאI53NP>אن C# Damaged("my car"); ﻛﻮد VB Damaged("my car") ﻛﻮد ً ^3iHאKS!\، 9مC ذK.:. \!ذאنא9 אمevent==null אHIאNP>ً MQCو .9مCS 3$ :5jP אE$L! دאאs9،17I C# Car.EngineHandler d = new Car.CarEventHandler(CarExploded); ﻛﻮد VB Dim d As Car.EngineHandler = New Car.CarEventHandler(CarExploded) ﻛﻮد 225 WوאK\*אNאnDzNHHg&אS'و1\אFg\אWON CarExplodedא$אoQQ :ً ^3אKPT،DamagedE$LאU:Hא C# public void CarExploded(string msg) { Console.WriteLine(msg); } ﻛﻮد VB Public Sub CarExploded (ByVal msg As String) Console.WriteLine(msg) End Sub ﻛﻮد C# ﻓﻘﻂ ﻓﻲAnonymous Methods اﻟـ .3 q3 אم$+دאzD$אP3نC¤H$]! Delegates אل5DسאH$אD' א$.Nذא . Delegate 'عNא53 :4F.WאE$LאK^F!אدאsאP3אن¤H$Rb אEvents XسאصH$א$و :ً ^3 אKPT C# t.SomeEvent += new SomeDelegate(MyEventHandler); ﻛﻮد 53אو$אoQoP\א53'نP אW،a7!نP\אאWSUA'א$אzD$א$Q9ضאZONوאن oQ P3 Anonymous Methods fQ 3 N g(Q NS ، Delegate U SzD$ א . 'دPאaאو$א :ً ^3'دאPאAN C# t.SomeEvent += delegate{ Console.WriteLine("Some Text"); } ﻛﻮد 226 ، a7! g3א$+ א0.'3 U א$ אoQ P3 אنb אA F . C# 03 a7! 5P وRb אWS :ً ^3אKPThאZ3Hi$DK7א$'ن אPًאنMQא5P> C# t.SomeEvent += delegate(object sender, CarEventArgs e){ Console.WriteLine("Some Text {0}",e.msg); } ﻛﻮد .g!gOQtאא$אUi'د%'\אh אq\אKV אنAnonymous method نאلP3ًMQC اﺳﺘﻨﺘﺎج اﻧﻮع اﻟﻤﺘﻐﻴﺮات .4 :אKPT:D' $Q$ دونq3oQnD5QHد.N،6`'אلOمאQCU VB Dim x x=10 ﻛﻮد UًD'N39אאWSK^3نYU، Object 'عNא53ًj$3gOQ'م7Q `'אلOنא0.א'אU .אjD0tאhqא :ً ^3אKPT:D'$Q$%Lونא$ q3oQXH,نאP3b א،.net 200803 C# var x = 2.3 // double ﻛﻮد VB Dim x = 2.3 ‘ double ﻛﻮد ً ^3NP>5!،ًאHW55P،hא53א 'عK"nDHد. q3oQ'SFאlWS53f$kא نC var K5P>9ً אIC،k return value אلUوCא$אhאZ3HU אو،i,3JOאU var oQ . = null F. KFd :g! var אم$+א5P>9 tאz1Iא0F®א\^لא 227 C# class classname { // i,3JOאU:OQ5P>9 ﻛﻮد private var varInt = 10; // ¤אوZ3HoQא5P>9 return value . var functionname(var x, var y) { } void somefunction() { // F.KFdאن5P>9 null var varNull=null; // F.KFdאن5P>97Q1אlWgn وnull var? varNullable = 12; // F.Y53$9 var m; } } Extension Methods اﻟﺪوال اﻟﻤﻤﺘﺪة .5 nD KQ$ אb אlWS ، i$Q$ א.net 2008 'אصI 53 i$ وאExtension Methods ~א .i$Q$%ودوאلC!دאsًوא73i'د%'3hJ! م$+دאKF'م7N،وZP9א$Q4אRb53$]'م7 string JO!دאsא$QNضאZON :ً ^3אKPTRegex C# public static class Extensions { Public static bool IsValidEmailAddress(this string s) { Regex regex = new Regex(@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"); return regex.IsMatch(s); } } ﻛﻮد 228 ﻛﻮد VB Imports System.Runtime.CompilerServices Module StringExtensions <Extension()>_ Public Function IsValidEmailAddress(ByVal s As String) As Boolean Dim regex As New Regex("\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*") Return regex.IsMatch(s) End Function End Module :אKPT string q3oQKPNNP>،وאن C# string mailExample = "email@mail. com"; MessageBox.Show(mailExample.IsValidEmailAddress.toString()); ﻛﻮد VB Dim mailExample As String = "email@mail. com" MessageBox.Show(mailExample.IsValidEmailAddress.toString()) Automatic Properties ﻛﻮد .6 :ً ^3אKPTPوאizא7 Get وSet دوאلoQ'م7N Properties zTאK%א53ًو7 C# public class myclass { private string _name; public string name { get {return _name} set {_name=value} } ﻛﻮد VB Public Class [myclass] Private _name As String Public Property name() As String ﻛﻮد 229 Get Return _name End Get Set _name = value End Set End Property End Class :אKPT 'دPאP3bאنא C# public class myclass { public string name{get; set;} } ﻛﻮد VB Public Class [myclass] Public Property name() As String Get End Get Set End Set End Property End Class ﻛﻮد Lambda Expressions ﺗﻌﺒﻴﺮات ﻻﻣﺪا .7 نP3 U א$ 'د א53 NNPe t אAnonymous Methods 5D 'عs'3 U N$ $. N K7tאدא$Dא5DRg!'م7!'OV3ضZON ،a7!i$وאi3A'gD$5N3د3SzD$א :2nDF7א C# static void TraditionalDelegateSyntax() { List<int> list = new List<int>(); list.AddRange(new int[] { 20, 1, 4, 8, 9, 44 }); Predicate<int> callback = new Predicate<int>(IsEvenNumber); ﻛﻮد 230 List<int> evenNumbers = list.FindAll(callback); Console.WriteLine("Here are your even numbers:"); foreach (int evenNumber in evenNumbers) { Console.Write("{0}\t", evenNumber); } } static bool IsEvenNumber(int i) { return (i % 2) == 0; } VB Private Shared Sub TraditionalDelegateSyntax() Dim list As New List(Of Integer)() list.AddRange(New Integer() {20, 1, 4, 8, 9, 44}) Dim callback As New Predicate(Of Integer)(IsEvenNumber) Dim evenNumbers As List(Of Integer) = list.FindAll(callback) Console.WriteLine("Here are your even numbers:") For Each evenNumber As Integer In evenNumbers Console.Write("{0}" & Chr(9) & "", evenNumber) Next End Sub Private Shared Function IsEvenNumber(ByVal i As Integer) As Boolean Return (i Mod 2) = 0 End Function ﻛﻮد :fFאKPTgND1 b אC# 2008 53 Anonymous Methods KN3א$+א03 C# List<int> list = new List<int>(); list.AddRange(new int[] { 20, 1, 4, 8, 9, 44 }); ﻛﻮد List<int> evenNumbers = list.FindAll(delegate(int i) { return (i % 2) == 0; } ); Console.WriteLine("Here are your even numbers:"); foreach (int evenNumber in evenNumbers) { Console.Write("{0}\t", evenNumber); } KPT g 5P> t وא، Lambda Expressions fQ 3 אم$+' אS .net 2008 U $Q$א :א 231 ﻛﻮد X => f(X) :אKPT i%2==0 U True $tوאNbאא$'نאPאW C# (int i) => (i % 2) == 0; ﻛﻮد VB Function(i As Integer) (i Mod 2) = 0 ﻛﻮد f' Lambda نZ3H'عאoQ5DzNq9אnNP>، int :D'و،Z3H אS i אنאل :אKPTK3P'دאP'نאPאW،ًj7:Df C# List<int> list = new List<int>(); list.AddRange(new int[] { 20, 1, 4, 8, 9, 44 }); List<int> evenNumbers = list.FindAll(i => (i % 2) == 0); Console.WriteLine("Here are your even numbers:"); foreach (int evenNumber in evenNumbers) { Console.Write("{0}\t", evenNumber); } ﻛﻮد VB Dim list As New List(Of Integer)() list.AddRange(New Integer() {20, 1, 4, 8, 9, 44}) Dim evenNumbers As List(Of Integer) = list.FindAll(Function(i) (i Mod 2) = 0) Console.WriteLine("Here are your even numbers:") For Each evenNumber As Integer In evenNumbers Console.Write("{0}" & vbTab, evenNumber) Next ﻛﻮد : return value :א\^لאnD ع9אNP>،a7! true , false وCi$وאF.iدDאa7!@NNP> 232 C# List<int> evenNumbers = list.FindAll((i) => { Console.WriteLine("value of i is currently: {0}", i); bool isEven = ((i % 2) == 0); return isEven; }); ﻛﻮد ...א$אGوذ،Z3H53^אQe NNP>ًMQC : Lambda ﻣﻮاﺻﻔﺎت .אbILambdae9− .OverridesوCOverloadsK^3OOPد¨אل3אم$+א5P>9− .ًj7h אq\جאNאQذ539$وiא\دF7'عא$Q$RAS.م$+9− .ًMQCدאzD$א5P>و،IzToQ@'د'دو%و53$9 אKIدא− .i,3א$א.iدDאQKReturnאم$+אQ9− .LambdaU{}وCEnd$%'Q9− .VBUOptinalאم$+א5P>9− .Genericאم$+א5P>9− Object Initializer Syntax ﺻﻴﻎ اﻧﺸﺎء اﻟﻜﺎﺋﻨﺎت .8 9*אjVI'tאYO&'\אJ! 5DQ^3אi$ضNa7!،سH$אאWSUً^ אK15 .G\وאFوא : .net 2008 K.3א\^لאول C# public class Employee { private string _name; private string _age; private string _salary; public string name { get {return _name;} set { _name = value; } ﻛﻮد 233 } public string age { get {return _age;} set { _age = value; } } public string salary { get {return _salary;} set { _salary = value; } } } VB Public Class Employee Private _name As String Private _age As String Private _salary As String Public Property name() As String Get Return _name End Get Set _name = value End Set End Property Public Property age() As String Get Return _age End Get Set _age = value End Set End Property Public Property salary() As String Get Return _salary End Get Set _salary = value End Set End Property End Class ﻛﻮد 234 :سHدUSNFt אautomatic property אم$+ و.net 2008 03^א\^لא C# public class Employee { public string name{get;set;} public string age{get;set;} public string salary{get;set;} } ﻛﻮد VB Public Class Employee Public Property name() As String Get End Get Set End Set End Property ﻛﻮد Public Property age() As String Get End Get Set End Set End Property Public Property salary() As String Get End Get Set End Set End Property End Class 'لb' א$Q ، .net 2008 53 $Q$ אObject Initializer Syntax אم$+ א03א\^ل א^ و : אKPT'دGPNאU،7قא1א$]gOQNt*אjVא C# Employee e = new Employee(); e.Name="Ahmed"; e.Age=15; e.salary=6000; ﻛﻮد 235 VB Dim e As Employee = New Employee() e.Name = "Ahmed" e.Age = 15 e.salary = 6000 ﻛﻮد :NS$Q$א C# Employee e = new Employee { Name = "Ahmed", Age = 15, salary=6000 }; ﻛﻮد ﻛﻮد VB Dim e As Employee = New Employee With {.Name="Ahmed" ,.Age=15,.Salary=1500} Anonymous Types اﻻﻧﻮاع اﻟﻤﺠﻬﻮﻟﺔ .9 nD f f' سH$א אWS U ، .net 2008 U i$Q$* אjV אv, سH$א אWS U Kb'א .Anonymous Types $ !אن3א،XH,אU var FPאمא$+'gh אq3oQNP3 אنNFNאnN9 'دPא(א،3$7\אUً ^ אKא5،ًMQ'אgא'אعoQP3Ka7!Q'k'אgh אq3 : א C# var e = new { Name = "Ahmed", Age = 20 }; ﻛﻮد VB Dim e = New With {.Name = "Ahmed", .Age = 20} ﻛﻮد . ً b אJOאoQون$ e.Age وe.Name izא.P3bאنא :VjVI nD 'd 'g! אW System.Object i,3 lدN אQ Anonymous Types ! ً אل .9א 236 . ﻣﺎذا اﺳﺘﻔﻴﺪ ؟ 9 א م وB 2 izא. 'دNض אZON ، م9 אB 2N a J! oQ NNP> LINQ U :אKPTذQ،2NאKP,ًא$Q$ C# var result = from emp in employee select new { emp.Name, emp.Salary }; ﻛﻮد VB Dim namePriceQuery = From emp In employee Select emp.Name, emp.Salary ﻛﻮد : Key Properties اﻟﺨﺼﺎﺋﺺ اﻟﻤﻔﺘﺎﺣﻴﺔ H'3Ci$Qאد5DO\*אjVאo§ Y'gYD'Yiא\وאH7\a7!O\*אjVمא$+− a7!izא7Fjدאg!O\*אjVא. q5P>9− .'g¡א'אعאK%C53%Z\אl$'QWאHash Code~א5FsgNFMQO\*אjVאa7!− Equality اﻟﻤﺴﺎواة 3} ©\'م א7Q'ل وg¡'ع אN@ אON h אq3 'نP 3$ND Qو3 'g¡ א'אع אh אq3 'نP :وطאTאFg!h!''عذאN@אO535Q qF5Q q3 .Scope@אلOUFgNDQVא− L zאH73'نPوGZ@אONgNDQV'عوאNوא9@אOFgVjVIe − .fא .C*jV+iد$)g!*jV@אO− .K.אnDi$وאCbI'عK>− .a7!:ONQو3'نPQO3bIC>9'لg'ع5DQVوא ...O\*אjVא. q5P>9:C@N9F 237 Partial Methods .10 53^אU JOאP3אنK،i$ وא71N3U JOא0sوnDًא4אن$_،$Q$,HVI J!0Q'SKi$Q$%J!@lWSאنnDل$JOאאUPartialFPمא$+אنOPQ،0s'3 :ً ^3אKPT،IنP3 U!3 C# partial class Car { } ﻛﻮد VB Partial Class Car ﻛﻮد End Class $ _ ، Partial Methods fQ 3 ًאIp3g& ذ$ 5P و، .net 2005 VD 03 אWS ن :אKPTذQ،ًMQא$نوאP3Uא$אPًא1M3 C# partial void methodname(string parm) { ﻛﻮد } VB Private Partial Sub methodname(ByVal parm As String) ﻛﻮد End Sub oQ%Lونא$kودوא9אhJO*אjVIQ'1U 'ع^ ًאs'\אאWS!دC،ª Fً .gN3i$Q$%+ 238 Garbage Collector .11 Qn3وiאWאUgNQ§QoNO_ ]لNNPو،א..hJ!وh אq3fN7אNوH لدI . GC وאلObject lifetime אلSO3 لI53سH$אאWSUgD G<f'J9אlWS،g!W אWS TQ refernce XًPV0. !¦ 'אOBJECT FROM CLASS J!535jPOQ$ND .234صI stack UًMQא$%'Q reference אאلWS، heap אلU'د%'\א5jPא :'אS1'نא¯لאP، stack אل53 reference אلfWQא$אzgאوא234א قא$ garbage אلdQ ، k TQ 53 ${ 9 t אhNjP אhJ} iאW א±e f' L אlWS Uو 77LאUאو،3$+\ אhJOאfWr'م7Qאא¯لWS53 GC ًאHVIא:3QWوאcollector .234אKIدא53g'لb'אP3$Q_tאhJOא0B fWr'م7Q'g! GC 03 אن3 א، אول ]ول3$+3 q א אq3 fWr 'م7 ض אنZO\ א53 نC++ م אلQ אU .T دونאنSWONQمg\אK%Rb! 53NjfWL GC Ki,3iH,א1Q9אWS0.א'אU، =null KF 'م7אنSًD',^9אLא .ً ^3iאWא±e3$ND،gPRאNP>93(LU:!W:NP ،iאWא GC اﻟﻔﺌﺔ .11.1 Pro X 53 iH'b lWS ، g3 ,\ אK3 א53 NPe tאول א$ א53 د$D nD GC JO' א :g3א$+وאلوא$אCsharp 2008 239 : Finalize() K. مg\ אWON و: overriding KFD NP> ، 5jP אfW .ص وN. א53 E$Lא אWS NP> .5jP א3$ :אKPTذQ C# class example { ~example() { Console.Beep(); } } ﻛﻮد 240 VB Class example Protected Overrides Sub Finalize() Try Console.Beep() Finally MyBase.Finalize() End Try End Sub End Class ﻛﻮد Operator Overloading .12 53 q\^ ًאF!،gN37T\אhJOאnDhFD WONO+\אh 3\مא$+،Nj'אعא9אU .א...v:אnD−،0B:אnD + K3\אgOQ Integer 'ع .אWPSو،YV23$:אnDً ^3+ q\אgO String 'ع53h אq\ ً אMQא :ً ^3אKPT Point 'ع53 Structure KFNF.'אن C# public struct Point { private int x, y; public Point(int xPos, int yPos) { x = xPos; y = yPos; } } ﻛﻮد VB Public Structure Point Private x As Integer, y As Integer Public Sub New(ByVal xPos As Integer, ByVal yPos As Integer) x = xPos y = yPos End Sub End Structure ﻛﻮد 241 53، 2N א$STאن:.'3،ط7Nאvو0F −אو+K3\אمא$+وא،ط7i$DoQ X%אن Uא9،ً3FgBوC، y אאلW אوو53^א17NאU x אلv5DiHD'نPQنCضZO\א v1وא0Fאh 33 D$Q9 Point nF\ אstructure ]ن¤$O]1IHnDA'KV 50.א'א : אstructure אلvو0Bh 33!s'م7Nאن C# public struct Point { private int x, y; public Point(int xPos, int yPos) { x = xPos; y = yPos; } public static Point operator + (Point p1, Point p2) { return new Point(p1.x + p2.x, p1.y + p2.y); } public static Point operator - (Point p1, Point p2) { return new Point(p1.x - p2.x, p1.y - p2.y); } } ﻛﻮد VB Public Structure Point Private x As Integer, y As Integer Public Sub New(ByVal xPos As Integer, ByVal yPos As Integer) x = xPos y = yPos End Sub Public Shared Operator +(ByVal p1 As Point, ByVal p2 As Point) As Point Return New Point(p1.x + p2.x, p1.y + p2.y) End Operator Public Shared Operator -(ByVal p1 As Point, ByVal p2 As Point) As Point Return New Point(p1.x - p2.x, p1.y - p2.y) End Operator End Structure ﻛﻮد :אKPT'دNP>אن 242 C# Point p3 = p1 + p2; ﻛﻮد VB Dim p3 As Point = p1 + p2 ﻛﻮد . Points אل0BFRRV`אNאnDKVR :i,3'دNP>ً MQC C# p2-=p1; ﻛﻮد VB p2-=p1 ﻛﻮد 53 Static function oQnD A'ًאHد.'نP5C 'S'عs'\אאWg QF!:DfN3I .K33 overloading KFDK%א 53 ذ 'عKFD NP> K ، overloading KFD 5P> 53 a7! v1 وא0F אh 33 :a7!XH,אU−−و++ً ^F!،h 3\א C# public static Point operator ++(Point p1) { return new Point(p1.x+1, p1.y+1); } public static Point operator --(Point p1) { return new Point(p1.x-1, p1.y-1); } ﻛﻮد א$ overriding KFD 03 ً 7 NF 3 K^3 77 =! وC == KFD وiوאل א\وא$ N 3@ אO :אKPTא$אlWSnDNS$FN،Equals C# public override bool Equals(object o) { return o.ToString() == this.ToString(); } public static bool operator ==(Point p1, Point p2) { return p1.Equals(p2); ﻛﻮد 243 } public static bool operator !=(Point p1, Point p2) { return !p1.Equals(p2); } VB Public Overloads Overrides Function Equals(ByVal o As Object) As Boolean Return o.ToString() = Me.ToString() End Function Public Shared Operator =(ByVal p1 As Point, ByVal p2 As Point) As Boolean Return p1.Equals(p2) End Operator Public Shared Operator <>(ByVal p1 As Point, ByVal p2 As Point) As Boolean Return Not p1.Equals(p2) End Operator ﻛﻮد :h 3\אlWS53 overloading KFDP3אن${אWPSو Pointers اﻟـﻤﺆﺷﺮات .13 !W5P_'3C،W5P_ '3C، pointer nN3¤H$$]]!، C++ 2343Nذא *§t وאpointer type ًאلMQא¤NS، refernce type وאلvalue type !אلs9:אfאن .iאWאUN3 53אiH,9 ذKF unsafe code אم$+91MK،1'دאPאUg3K3 5א:!3ولCQא$ g3א$+ON vFً9אو.אW، pointers אل03K3ًsאZ!אF5XH,ن אC :אKPT 244 :ً ^3אKPT pointers אل03K3Q 'دNP>'دאصP لאI53وאن C# class Program { static void Main(string[] args) { unsafe { // Work with pointer types here! } // Can't work with pointers here! } } ﻛﻮد :^3אU'صqאنK. pointersאل03K3אnDNNtא אhאدوאnDfNאن אم$+9א hאدوא pointeroQم$+ * iאWאU q\'אنאND !\ & t אJO אKI دא3 K7 'لb' م$+ -> pointer אلg TQ .:! IوH7\وאhא,p\א5Fs¤Rא !=،== ،- ،+ ،-- ،++ UKF'אg@ON'نPQ5 unsafe code אل03K3אنאoTPf' سH$אאWSUHאFא03 .QאدXH, لI 53safe code 245 ؟unsafe code وﻟﻜﻦ ﻟﻤﺎذا اﺳﺘﺨﺪم ال .FאضC • . pointers لI53ً bאKFt אCOM Components אوאلdll's אل3א$+א • .iאW,\'لאb' ل אI53N3Fg3DوzאدאY)و • نImage Processing hFD KF 3 iH'b pixels izא. zNC وN ج אص+وع אT3 U Q'FD'نPgNPو،Pوאizא7H'Vb אSetPixel وGetPixel אمدوאل$+אNP3 אل03 K3 وאunsafe code אم$+ نKQ$ אKL א، 7Q1 אlWg pixels ~ אnD HوF ًא$% وGetpixel 7Q1 YH'bv1^ ً'د3X%،iH'Vb אpixels אلnDHوFi,3pointers ... قHO4IC و،pointers אم$+AICi3g%سH$אlWS$و،setpixel ...اﻵن ﺳﻨﻌﻮد ﻣﺮة أﺧﺮى ﻟﻨﺸﺮح ﻣﻦ اﻟﺒﺪاﻳﺔ :אKPT pointer oQאنNP> C# public Node* Left; ﻛﻮد :אKPT unsafe 'عNא53 class אوstructure oQP3K،a7!אWS@ C# public { public public public } ﻛﻮد unsafe struct Node int Value; Node* Left; Node* Right; 246 :ً MQودאאC C# public { public public public } ﻛﻮد unsafe struct Node int Value; Node* Left; Node* Right; VB unsafe static void SquareIntPointer(int* myIntPointer) { // Square the value just for a test. *myIntPointer *= *myIntPointer; } ﻛﻮد :אKPT & אم$+Z3HאKNذن،Z3H אU q\אoQ*N3$+א$.N\و C# SquareIntPointer(&myInt2); ﻛﻮد :ً ^3אKPT -> م$+N Node אلU Left q\'ل אb'ًMQC C# n->Left=5; ﻛﻮد ؟VB.net وﻣﺎذا ﻋﻦ i) Marshal JO '! א5P و، i,3 hא,p\ א53 iدO9 אNP> 5! VB.net 2343 N ' :C#'دאPضאZON،hא,p\_אD53Q. C# unsafe {BitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ﻛﻮد 247 ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); byte * pixel = (byte*)(void*)bmpData.Scan0;//the last syntax is equivalent to: //byte* pixel = (byte*)bmpData.Scan0.ToPointer(); pixel[0] = 255; pixel += 4; pixel[0] = 0; } :אKPTVBUg71 ﻛﻮد VB Dim width As Integer = bitmap.Width Dim height As Integer = bitmap.Height Dim bmpData As BitmapData = bitmap.LockBits(New Rectangle(0, 0, width, height) _ , System.Drawing.Imaging.ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb) Marshal.WriteByte(bmpData.Scan0, bmpData.Stride, 255) Marshal.WriteByte(bmpData.Scan0, bmpData.Stride + 4, 0) bitmap.UnlockBits(bmpData) .א\^لGb$و PTא03*** Query Expressions .14 HVI NS gD fN ، LINQ _D U אو وאi'1 אS Query Expressions אل4 K3אC$FN3د7'لאVOKbOא. K%pNF! .net 2008 hא53i$Q$%iF$Q$, .hא$D'א.03Oא :ً ^3אא\^لWSAN C# from d in developers where d.Language =="C#" select d.Name; ﻛﻮد VB From d In developers ﻛﻮد 248 Where d.Language ="C#" Select d.Name :אKPTً7gnDh'دt مא9 אBA')'SaMאWS SQL Server select name from developers where language=’C#’ ﻛﻮد إذن ﻟﻤﺎذا ﻫﺬا اﻟﺸﻜﻞ اﻟﺠﺪﻳﺪ ؟ KP, nD 2N و'دh אi$D. U SWON م9 אB لH 'م7 N אU .g4'م7t אqאhQ')53z% م9אKBRbאنא3C،5PQFg3وCDataReader :אWSz لא$QH'53$ ! LINQ nDKF C# using System.Linq; ﻛﻮد VB Imports System.Linq ﻛﻮد nDhF אX`NאW،gN3z%CوC Array 5DiHDShאi$D.אنnD LINQ אل$F :ً ^3אKPTضאZON، Array אل ﻛﻮد C# string[] userNames = {"Ahmed", "Ali","Mohammed", "Ahmed","Ramy", "Khaled"}; VB Dim userNames As String() = {"Ahmed", "Ali", "Mohammed", "Ahmed", "Ramy", "Khaled"} ﻛﻮد ﻣﻼﺣﻈﺔ ' אن אوS قHO א، Query Expressions لS א3 H$. LINQ ~ S א9 NS c] ^ ًא¤ אذ5 ق1 دون אa7! P אO F g! ^ א3 אgD א'אo+} h א$D'א. 03 K3 bI .h א$D'א.*jV 249 BzNولRNאن،I z,C'نP$.، XML o3'نP$.،h i$D.'نP$.!'OV\אlWS "Ahmed"وtאz9אizא7 א م C# IEnumerable<string> subset = from users in userNames where users == "Ahmed" orderby users select users; ﻛﻮد VB Dim subset As IEnumerable = From users In userNames Where users = "Ahmed"OrderBy users Select users ﻛﻮد : אKPTgDאنNP>אW، array ً MQ'نאP2Nא C# foreach (string s in subset) Console.WriteLine("Item: {0}", s); ﻛﻮد VB For Each s As String In subset Console.WriteLine("Item: {0}", s) Next ﻛﻮد E 53א'لz9ضאRRbאF!אW، C# دوאل53אمאدא$+ א01NP> :fو C# IEnumerable<string> subset = from users in userNames where users.Length > 3 orderby users select users; ﻛﻮد VB Dim subset As IEnumerable = From users In userNames Where users.Length > 3 OrderBy users Select users ﻛﻮد 2NאنאK753^א5DN 'ًb'VI،S(אh!'عא3nDًאHد.'نP9$.ًMQC 9}HًMQא،ً7SN,t אData Type ون$ Dim وאلC var אلi$j!Ng(NS،J!'نPQאن$9 سH دUًMQאSN,t وאNullable Types אلi$j!NS0%ZNאW`N م9 אB'د 250 .3د.3UgDfNو، Lambada אم$+KFאlWSPAIC7Q Preprocessor Directives .15 :ً ^3אKPTאnD^3U h دوאnوCiSא0QHTFאو23א4ROV لIً^ א g. وאgR!QrN3ود$5Fs'אد9א53D'F0s' 7QgאfFD$nDNو Regions אلlWSنCسH$אאWSU:!3אن9،'دPאzNC¼Q'Tم א$DنFM'g .سH$א אWSUً VOgDfNt אPreprocessor Directives אل53D'FSg! Iو #region, #endregion .15.1 :ً ^3אKPTg5P>،ً7ذF אصcs o3U 'دPאg(3NiدDم$+ C# #region "Class Employee" public class Employee { private string _name; private string _age; private string _salary; public string name { get { return _name; } set { _name = value; } } public string age { get { return _age; } set { _age = value; } ﻛﻮد 251 } public string name { get { return _salary; } set { _salary = value; } } } #endregion VB #Region "Class Employee" Public Class Employee Private _name As String Private _age As String Private _salary As String Public Property name() As String Get Return _name End Get Set _name = value End Set End Property Public Property age() As String Get Return _age End Get Set _age = value End Set End Property Public Property name() As String Get Return _salary End Get Set _salary = value End Set End Property End Class #End Region ﻛﻮد 252 :ً ^3אKPTًF(N3¤'ن'دPQr ،f1א53g. وאgR!NP>אن #if, #elif, #else, #endif .14.2 N3h9U'دPא53N3zא%אWONم$+و، Conditional Code Compilation אgD1Q 'دPאGP Release אل.وU@ وDebug אل.و9a7!KFQ9'دPא53z%K ً ^F!،a7! אKPT C# #if DEBUG Console.WriteLine("App directory: {0}", Environment.CurrentDirectory); Console.WriteLine("Box: {0}", Environment.MachineName); Console.WriteLine("OS: {0}", ﻛﻮد 253 Environment.OSVersion); Console.WriteLine(".NET Version: {0}", Environment.Version); #endif VB #If DEBUG Then Console.WriteLine("App directory: {0}", Environment.CurrentDirectory) Console.WriteLine("Box: {0}", Environment.MachineName) Console.WriteLine("OS: {0}", Environment.OSVersion) Console.WriteLine(".NET Version: {0}", Environment.Version) #End If ﻛﻮد . elif وelse אم$+א5P>7Q1@אON #define, #undef .15.3 صI symbol oQNP>אو، Debug K symbol oQNP> ً ^3،Y3 symbol oQم$+ KFD Q 'دPא אWS אنcQ Symbol oQ ^ ص3 א\^ل א، ً 79 :3א$+ ] א א . Mono nDa7! :Debug :אKPT'دNP>ً79 C# ﻛﻮد 254 #define DEBUG #define MONO_BUILD using System; namespace PreprocessorDirectives { class Program { static void Main(string[] args) { #if MONO_BUILD Console.WriteLine("Compiling under Mono!"); #else Console.WriteLine("Compiling under Microsoft .NET"); #endif } } } VB #Define DEBUG #Define MONO_BUILD Imports System Namespace PreprocessorDirectives Class Program Private Shared Sub Main(ByVal args As String()) #If MONO_BUILD Then Console.WriteLine("Compiling under Mono!") #Else Console.WriteLine("Compiling under Microsoft .NET") Dim INDEXERS As n, OPERATORS As n, [AND] As n POINTERS 413 #End If End Sub End Class End Namespace ﻛﻮد 255 XML Commenting .16 ،i Pא0QHT\ אUًb'VIFSאQUًא3C$Q'אد Comments KFD!¦ن0.א'אU $ ' وn :D لF9 وא¤! 'د3 $g א53 K7 I *+, א01Q F ¤ 'د.א3 01 . ًא$%Q' iZO'دP@אOUKFא5DO.' אKPT Comment אلKFDQ،وسH$אlWShQא$UN!DFو C# // here we will do something, set x=startvalue x = FirstClass.Default(); ﻛﻮد VB ' here we will do something, set x=startvalue x = FirstClass.Default() ﻛﻮد Qא3 i$D N !'Q } XML X'] Comments אل53 NNPe ، i$Q$% 7Q nD fN אن .سH$ لאIgDfN ﻣﻼﺣﻈﺔ . javadoc من خاللJava من اوائل اللغات التي طبقت ھذه الطريقة كانت W'دوאPbIh3 DC0sو01 3 אlWS0sو$،///0s لوI53Qא$ذQ KMOQtא7אbNא53D'F¤NS، XML ¨د31Q دאم3 XML نCnDً7903K3א .SO\ א$'g3א$+א אم$+9א VNא oax ضQنC$9 אنא$Q$R <c> 'دP :3K3א19دא$אن$Q$R <code> X'P\'دאPאvT^ل3$Q$ <example> אWS 5D 2N אن5P> t אz1I وאhאzN^9 אnD 'd W אo\א <exception> JOو אC'دPא 256 DocumentationאلKIאولدא$%Fj.אجHאد <list> Y3Z3HvT <param> Y3 zQFLאKjوobو <permission> BuildאلhאHI <remarks> return;א$א2obو <returns> Documentationאل53IzIaאH <see> (ً MQ)א(א5Pو،אK^3 <seealso> vوT\ אz`Bאobو <summary> N3bIob' <value> ﻣﺎ ﻫﻲ اﻟﻔﺎﺋﺪة اﻟﺘﻲ ﺳﺘﺠﻨﻴﻬﺎ إذا اﺳﺘﺨﺪﻣﺖ ﻫﺬه اﻟﻄﺮﻳﻘﺔ، واﻵن ﻻ ﻣﻦ اﻟﻄﺮﻳﻘﺔ اﻟﺘﻘﻠﻴﺪﻳﺔ ؟؟؟ ً ﺑﺪ :ً ^3YO&'\אJO Q3ً ^3X%،ً9وC C# /// <summary> /// Employee Class of the company /// </summary> partial class Employee { /// <summary> /// /// </summary> /// <param name="Firstname">first name of the employee</param> /// <param name="Lastname">last name of the employee</param> /// <param name="age">age of the employee</param> public Employee(string Firstname, string Lastname, int age) { } } ﻛﻮد VB ''' <summary> ''' Employee Class of the company ''' </summary> Partial Class Employee ﻛﻮد 257 ''' ''' ''' ''' ''' ''' <summary> </summary> <param name="Firstname">first name of the employee</param> <param name="Lastname">last name of the employee</param> <param name="age">age of the employee</param> Public Sub New(ByVal Firstname As String, ByVal Lastname As String, ByVal age As Integer) End Sub End Class :אiH'Vאª9،'دPאKFDאنX%و ؟W@א،7Q!43.ًRsوאg(Q'دPאbא،قHO(א9 KS : Documentation ﻧﻘﻄﺔ أﺧﺮى lWS nD د ًאFD אDوT\ 3 Documentation אجI אNP> ، Build אلhאHI 5Fs 53 ً وMQא :אKPT XML o3אجHI. وBuild HI.وعT\*אjVI53 אW،א''م 258 :אWSK^3ًJ,$`،lHIF.Wאo\אאWk'لb' אX% : ﻣﺮة أﺧﺮىDocumentation ﻧﻘﻄﺔ ﺛﺎﻟﺜﺔ 5P> 5P ، 3'gO3 qV אXML אلKQ'R sאZ! אi אدאVisual Studio 2008 !'Q 9 o :iH'VאlWSK^3 אo\אKQ'R NDoc K^3iدאCאم$+א 259 ... Comments אل53a7! אWSK :אaאא53SourceforgeאلnD+Kb'אNP> رابط http://ndoc.sourceforge.net/ .net assemblies .17 F! g! 9ط א7N אfN NNP ^ ًא وg! K1 5 ، .net assemblies אل03 iZO אlWS $D'3 msdn لI53gND$Q\אnD ع9אNP> namespace اﻟـ .17.1 i$Q$אQHT3Uًو3אدوW،אgMAאن: h'P\א0F5P> namespace @אلOU h'P30F $'3 namespace K%א C# namespace example { ﻛﻮد 260 class someclass { void method(){ } } } VB Namespace example Class someclass Private Sub method() ﻛﻮد End Sub End Class End Namespace 7אא$א5Fs'دאPאNP>5!،I namespace U classCar J!NQ$'ن3C :method C# void method() { classCar x=new classCar(); } ﻛﻮد VB Private Sub method() Dim x As New classCar() End Sub ﻛﻮد אKPTJOאoQ 535PF example K import KFDNNP>5P C# using example; namespace example { class someclass { void method(){ } classCar x=new classCar(); } } ﻛﻮد 261 VB Imports example Namespace example Class someclass Private Sub method() ﻛﻮد End Sub Private x As New classCar() End Class End Namespace Default Namespace ﺗﻐﻴﻴﺮ ال .17.2 :sאZ!9אz9 لאq Format of a .NET Assembly ﺷﻜﻞ ﻣﻠﻒ اﻻﺳﻤﺒﻠﻲ .17.3 bNא53'نPQ9אoP3نCª אنNP>ً ^3 dumpbin.exe X9אo3OF.ذא :א Win32 file header 53KqT(אnDlWONO وdll אمGUI אمconsole 'SKS،o\אאWS'ع5Dh3'3$`NS . وز$NQو CLR file header 262 אل7Q nD 'd ، gFD$Q אن.net application $ 9 t אh3'\ אnD 'd .:! Iو:3$D53 resources 'دאل%ووmanaged file Q3'zNجN3ذאA'g3K35،Y7 אY17N7אh3'\^ אًאFg9 .net .KFDJ صI CIL code نK73سHدgND'نP،ً7gND N$t אJIT אم$+ًאH'!:BQ،4'دאصPא אz, Type metadata .Ug3$+tא%H'אع א9אKbOnD' An assembly manifest .:! Iو9אHא$bد א$،O+\א9אhO3Yaאא Optional embedded resources .:! Iوh'7QوאH'b TسH'QאhO3 53د$DאnD'dאن5P>אo3א Private Assemblies .17.4 visual אلRQ5،1אو א234אH3 لI53KFQאo3 Private Assemblies אل .:ND 234 אH3 U R a7! ، I نP3 C U אوZ® אU z 'אo\א אWS 5D studio i,3 : setup KFD$1אK7NP>ًMQא،:3hO\אlWSfWQfW U .(مN*אz,C03K3Q9:' .'عNאאWS53SgF'م7t אdll אوאلsאZ!9א9 אhO3 263 Shared Assemblies .17.5 ^א03K3אo\نאP3¦نK،אWS dll אلo3م$+Q53¤$'نوP 5NS،^'عאN'אSאWS 9 אo3 U S${ 3 iدD ، System.Windows.Forms.dl ً ^3 ، زg@ אO nD 1 53 .fW03g!WQ9وزو$NQ'אU'د%'\א 9no\אאWk unique 'د א%وiHوs'S'عNאאWS53אo3zTg3K317ولC COM globally unique fQ 3 ¤NS نCOMم אلQC ، AI אhO\ א. 03 XHMQ fQ 3 lz1D אD b אن א، $Q$% COM KP O z אz1D אQ ، identifier (GUID) :l$Q$Uאh'P\א¤ZTم.H9א53 128 :'و$Q9W وאstrong name .9אo3א • .9אo3+ • AssemblyKeyFile Ui'د%'\א- public key value • . AssemblyCulture UF.אhאد$D'دאא%وU • . public key وאل9אo3 hQ')Y hash אم$+:NQ'PQdigital signature • :ً ^3אKPT SDK’s sn.exe 234مא$+ public key KF ﻛﻮد sn -k MyTestKeyPair.snk 264 Multithreading اﻟﻤﺴﺎرات اﻟﻤﺘﻌﺪدة .18 ﻣﻘﺪﻣﺔ .18.1 @OUFg353^אWONP3אcQ 3'S وmultitasking systems g]^Q$LאKqT(אf ..'@אOU23 אi$DKqTP3نC${אW،.'א 53^אWONnDHد.$א'א234אنא23א4אUª NP،ًsאZ!'ع אNאאWS53 .net 23א . multithreading fQ3אWS،ضH3 ]Fk'نPQنCدون.'@אOUFD *+,53^א03E$R אوא3Pאمא$+وאQ$LوאhO3لH אQ`N\א23אن${אW gM 5D$א'א234אKIمدאg\אlWSKVOQ5PQ_':DًאHد.`N\א5PQ_3 'Sو،.'@אON .LאNH'ندFM3'SאWS، ﻣﻼﺣﻈﺔ لذا قم، System.Threadingجميع األوامر التي سنتعامل معھا ھنا تقع تحت نطاق األسماء ً باستيراده أوال :S אWSz9لאKIدא9אbNא ob'א VNא :3K3وא$Q$% Thread oQ Thread gNF!K3אk5P> Threads אل53D'F ThreadPool Threadh9i$DnD'dEnum ThreadState Thread UWON אz$ ThreadStart Thread אאلWSQ'אو$Q$ ThreadPriority 265 :!s9 Semaphore .1 Mutex .2 Monitor .3 אzאUgDfNtא53אאh3QH'א53D'FSو synchronization اﻟﺠﻮرﻳﺰﻣﺎت اﻟﺘﺰاﻣﻦ .18.2 Thread 53^FQ9r Synchronization 53אאhFم$+h3QH'سא9 אUSو :NS53z$א5P>h3QH'9 אlWSnDfא53$Q\،.'@אOUHدV\@אO'لb' رابط http://en.wikipedia.org/wiki/Semaphore_(programming) http://en.wikipedia.org/wiki/Mutual_exclusion http://en.wikipedia.org/wiki/Monitor_(synchronization) System.Threading.Thread .18.3 JOאlWSh'P3، gD O+\אN3g3WON وthreads zTאN،אWSz9لאU9 אJOא :S9א ob'א 'نP\א .'א53iZO thread אلKFDo.' Sleep() 9אمKFQ زאل3 thread ذאنאلs'F. IsAlive backgroundUKFQ thread ذאنאل IsBackground 266 LאQ'אو Priority Threadאل ThreadState threadאאل Name وجI Abort() joinUE$L אEو$n thread אلKFDo.' Join() :!7Qא$KFאfNJא Resume() אوiF KFאz$ Start() ً .p3KFאf7Qא Suspend() fNJ9S$'د،.'@אOU YFg3WONQאنnN3nDل9$ Q{KFQא$'م7N .'عs'\bאSO\אv, :'دאP`א. C# static void Main(string[] args) { order1(); order2(); Console.ReadKey(); } static void order1() { for (int i = 0; i < 100; i++) { Console.ForegroundColor = ConsoleColor.Green; Console.Write(i.ToString() + " "); } } static void order2() { for (int i = 100; i > 0; i--) { Console.ForegroundColor = ConsoleColor.Red; Console.Write(i.ToString() + " "); } } ﻛﻮد 267 VB Private Shared Sub Main(ByVal args As String()) ﻛﻮد order1() order2() Console.ReadKey() End Sub Private Shared Sub order1() For i As Integer = 0 To 99 Console.ForegroundColor = ConsoleColor.Green Console.Write(i.ToString() + " ") Next End Sub Private Shared Sub order2() For i As Integer = 100 To 1 Step -1 Console.ForegroundColor = ConsoleColor.Red Console.Write(i.ToString() + " ") Next End Sub ،زN א53و$DVאD'S1א2Nא،ًزNًوQ$DVم.HאD1 'م7Qs'وאSF'دPא :ً ^3אKPT2jNא,,'نP QO"^وאMIאאو$א2jDQYU oQ 'م7N אن3C ، zg9 אn ^ א53 وzg9 אn א אو$ אWON Q ، 1א אWSو @OUH'و4 אnDSWONgN3$وאnDدאKWONQrWONO threads :ً ^3'دאPא،.'א C# static void Main(string[] args) { System.Threading.Thread t1 = new System.Threading.Thread(order1); ﻛﻮد 268 t1.Start(); System.Threading.Thread t2 = new System.Threading.Thread(order2); t2.Start(); Console.ReadKey(); } static void order1() { for (int i = 0; i < 100; i++) { Console.ForegroundColor = ConsoleColor.Green; Console.Write(i.ToString() + " "); } } static void order2() { for (int i = 100; i > 0; i--) { Console.ForegroundColor = ConsoleColor.Red; Console.Write(i.ToString() + " "); } } VB Private Shared Sub Main(ByVal args As String()) Dim t1 As New System.Threading.Thread(AddressOf order1) t1.Start() ﻛﻮد Dim t2 As New System.Threading.Thread(AddressOf order2) t2.Start() Console.ReadKey() End Sub Private Shared Sub order1() For i As Integer = 0 To 99 Console.ForegroundColor = ConsoleColor.Green Console.Write(i.ToString() + " ") Next End Sub Private Shared Sub order2() For i As Integer = 100 To 1 Step -1 Console.ForegroundColor = ConsoleColor.Red Console.Write(i.ToString() + " ") Next End Sub 269 .2jNאANאن نC$`،2jNאX%وgN3$^ ً'א3 Priority אلqX%، i3KSF'نP52jNא01 :ً ^3'دאPא،^אK.:N3zg9אQnD אQ'אوGb C# t1.Priority = System.Threading.ThreadPriority.Highest; ﻛﻮد VB t1.Priority = System.Threading.ThreadPriority.Highest ﻛﻮد :אKPT2jNאV ..'אאWSUQ'SWON5Q'دPنאC'S$STא5P ،WONאUh! Iא$` 270 Priority اﻷوﻟﻮﻳﺔ .18.4 ذوthread אنאل،H'و4אnD threads لאلIאدQ3$NDWONאQ'وC Priority دאل$ : NQ$ضאنZO'مgO\אGQ7،WONhא3د$n(dnDאQ'و9א .A'V.Q'אو1Fg3 .1 .A'V.Q'אو2Fg3 .2 .אWPSو1،2،H'و41Fg\لאIאدQL אlWSU :אKPT3'نאPQ،K.אQ'אوh ذא2Fg3ل'نU3C zg9אnאWPSو... 2Fg\א، 1Fg\א، 1Fg\ א، 1Fg\א، 2Fg\א، 1Fg\א، 1Fg\א، 1Fg\א .FS$א53 א'אعi$D${،NS53z$אNP>iدQאhدHC'،H'و4אh3QH' אv,نP3אWS@ : scheduling אل53 رابط http://en.wikipedia.org/wiki/Scheduling_%28computing%29 : אenum مאل$+NQ$Fg3C Priority $Q$R،AICi3'د C# public enum ThreadPriority { AboveNormal, BelowNormal, Highest, Idle, Lowest, Normal, // Default value. TimeCritical ﻛﻮد 271 } VB Public Enum ThreadPriority AboveNormal BelowNormal Highest Idle Lowest Normal ' Default value. TimeCritical End Enum ﻛﻮد :ً ^3אKPT'دPאVQو C# t1.Priority = System.Threading.ThreadPriority.Highest; ﻛﻮد VB t1.Priority = System.Threading.ThreadPriority.Highest ﻛﻮد suspend ، i$\ WON אf7Q9 sleep אم$+ אP3 אنnN 9 ، 9 א0s א\'א5D $ אK. .سH$אאWkN,gC$tطא7Nא53א....p3f7Q9 ParameterizedThreadStart .18.5 5P،KVON3 thread USWONk start KF'م753אو$ אHNא\^لאאU(9 ؟hאZ3HK7א$אlWS 'ذא3 :ً ^3אKPT ParameterizedThreadStart אم$+ ،aKLא C# Thread t = new Thread(new ParameterizedThreadStart(functionname)); t.Start(parms); ﻛﻮد 272 VB Dim t As New Thread(New ParameterizedThreadStar(functionname)) t.Start(parms) ﻛﻮد ﻣﻼﺣﻈﺔ ولكن يمكن استخدامThreadStart لو كنت تود استخدام دالة تعود بقيمة فال يمكن استخدام ()EndInvoke )( وقراءة الناتج فيBeginInvoke foreground and background .18.6 : threads אل53نD'¤NS 0BWON53zg9אQnqQאن5P> 9234אنאcQאWS : Foreground Thread .'عNאאWS53'SlzT'م7 thread sאZ!9'عאN א،:!i'د%'\ אforeground threadsאل !אلWONQ_ 'n:. אQאن5P>234אنאcQאWS : Background Thread :ً ^3אKPT:FDQ،background threads C# t.IsBackground = true; ﻛﻮد VB t.IsBackground = true ﻛﻮد Threads Synchronization .18.7 3אא®دW،O+\אFDhאH3YKIא$KVd9C5FMQ$C ! Threadsאل03KF3$ND .سHدUًאVg,אtא53د¨אא31QWوאSyncLock~fQ ،KIא$CKVd9gI'ددאPאYFMQt وאSyncLock…End SyncLockאم$+אQ KPT ، zg א$ 9 KIא$ z@ ل אO U 'دF 9وH\א אWSHدV3 'م ق7 :ً ^3א 273 C# lock (myLock) { for (i = 0; i <= 1000; i++) { Console.WriteLine(i.ToString()); } Console.Write(number); } ﻛﻮد VB SyncLock myLock For i=0 To 1000 Console.WriteLine(i.ToString()) Next i Console.Write(number) End SyncLock ﻛﻮد .אW،ًMQCD1א3CوHאPא7zgא$9KFQאنmyLock q\مא$+QH3FQ5 .ً ^3number q\אF7KIא$:!KVdنCnT§نP3KUgs' :−אq–سאH$א53hאH\אU53אא5D$Q\!א3NP> رابط http://vb4arab.com/vb/showthread.php?t=6341 ThreadPool .18.8 U ¼Q'T 53 : G 3 وU hאH\ אi^P KQ$ אS – אb – نhאH\ אi r hאH\ א53 D'F 5Q'P ذQ ، :! I وHدV\ وא53 אא3وאC G a א53 ^P وא234א :234אUi^PSWONQ9tאhאH\אUi^א!دC'نذPQو،ZT\א C# for (int i = 1; i <= 5; i++) { ThreadPool.QueueUserWorkItem(sometask.Execute); } ﻛﻮد 274 VB For i As Integer = 1 To 5 ThreadPool.QueueUserWorkItem(AddressOf sometask.Execute) Next ﻛﻮد :−אq–سאH$ لאI53'عs'\אאWS5D$Q\!א3NP> رابط http://vb4arab.com/vb/showthread.php?t=6340 BackgroundWorker .18.9 53،2349אH\א5Dًא$ ً Q'ً.وWI]N3Fg3WON BackgroundWorker مאل$+ 53 h אG% אوH'V א3 hFD وC web service 53 izא7 bوאل א$^ ذ א3C .$3אQ'hFא53D'Fzא%אوא،rFD WONوCI'3' نC 9 ، $7 thread U SWON Q 5D وאل$ אlWS KFD P3¦ نC 03و U G tא א$ thread ~ אHI אNP> ، PR א53 $Q3 1 BackgroundWorker E$ WON Q WON אzg א$ ًאIC ، RunWorkerAsync()Q 5D gqT 53 وSWON .Fg\אlWSWONzg א$2jNضאDً ^3:!NP>tوאRunWorkerCompleted ،Fg\אWONz$3אHز0s53وhدوא9א.، Windows Form KF .KFz$ :ً ^3אKPT BackgroundWorker iدאCGR.ً אIوא 275 RunWorkerCompletedE$L وא، WON אz$ . وlzD$ אQ W وאDoWork NS FS Y دאSC :ً ^3 אKPTWONא53zg9א$:. אQWوא ﻛﻮد C# private void ProcessNumbersBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { } private void ProcessNumbersBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { } ﻛﻮد VB Private Sub ProcessNumbersBackgroundWorker_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs) End Sub Private Sub ProcessNumbersBackgroundWorker_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) End Sub :אKPTWONz$אQً79 C# ProcessNumbersBackgroundWorker.RunWorkerAsync(args); ﻛﻮد VB ProcessNumbersBackgroundWorker.RunWorkerAsync(args) ﻛﻮد . DoWork E$LאU'د%'\'دאPאWONQ 276 277 اﻟﺒﺎب 13 اﻻدﺧﺎل واﻻﺧﺮاج ﻓﻲ .net 278 279 System.IO اﻟﻔﺌﺎت اﻻﺳﺎﺳﻴﺔ ﻓﻲ .1 Binary KP,nDوizא. Files نC 5P> t אBuffer h .p3 ن BinaryReader BinaryWriter BufferedStream iאWًא79g7QWI] 7\אh3'\وאhא$¡א03K3* g hא$ و5D h3'\! א3 وK3 * Directory DirectoryInfo DriveInfo Driver¤زg%U5Q+א gQ3KوhO\א03K3* nD hض אD وhOF 'لb' א53 NP> File FileInfo FileStream StreamKP, C1tאh Q$¤HIوא$ אوo3.א3 FileSystemWatcher :D KQ'R VN אh אq\ א03 K3 * Path KqT(مאN3'gO3H'bhאH\א ViH'VhO\אPوאizא7א Reader אن אلf I א03 a7! ، @ אO String אل53lzTאQ Writer وאل StreamReader StreamWriter StringReader StringWriter .ً 3א$+אS^CوSg,CSlWS5Pو،z9 א53אא¡لWSUAIאhJ!¤NS Directory وDirectoryInfo اﻟﻔﻮارق ﺑﻴﻦ .2 3 אObject 53 i,3 7T3 Directory אن، g אصstructure אلU 'S ق אHOא K3אUقHO א3א، Objects אل53SHو$7T\ אFileStreamInfo53 7T3g! DirectoryInfo 280 03 3 א، i,3 g3א$+ א5P> r Static 'عN א53 k دوאf Directory JO' אن אg! .وאل$אمא$+אK. +oQ39אG1Qo39!DirectoryInfo ... FileInfo وFile YقOאnD1NQ39@ אO *jV !s אFileStreamInfoل9*אjVאg3KF FileInfo وDirectoryInfo YJO א :Sو،hא$¡وאhO\א03K3א ob'א bא 5D o\و אC $`F !s א. QF *§ Attributes nF\א enumeration אل Q FileAttributes zT9א¢QHوizא. CreationTime 9مC'د%'3o\אKS!3 Exists o\אدא$3א$ Extension $`FوCoF ً 3H\אnD'لVLא FullName אوo\ אnD 'لI$ ¢QH I وizא. LastAccessTime $¡א LastWriteTime אوo\אאWSUP¢QHIوizא. $¡א Name $¡وאCo\!אא3 DirectoryInfo اﻟﻔﺌﺔ .3 :وאلא$אnDJOאlWS'، FileStreamInfo 537*אjVאnDSz'א9!sא ob'א bوאCא$א د$[אH\אUD!$ אو$zTא Create() CreateSubdirectory() Delete() :Q')K3و$¡אfW 281 DOאhא$¡אzאs'z9א53!'OV3$ GetDirectories() hO\ ! אnD ' FileInfo 53 Array !'OV3 $ GetFiles() $¡אאWSU i'د%'\א $Q$%نP3:Q')!و$¡אK7 MoveTo() $¡אאWS5349א$¡!א3 Parent $¡אאWg אصDriver \!אل Root $T\ אU :N3 z$ 'د אWن אP\ אQe NP> ، JO אlWS 53 + oQ %r א، z$ אK. :( 234אH\)ً ^3אKPTConstructor C# DirectoryInfo dir1 = new DirectoryInfo("."); ﻛﻮد VB Dim dir1 As New DirectoryInfo(".") ﻛﻮد :دDH3وC C# DirectoryInfo dir1 = new DirectoryInfo(@"C:\Ahmed"); ﻛﻮد VB Dim dir1 As New DirectoryInfo("C:\Ahmed") ﻛﻮد ﻣﻼﺣﻈﺔ K^3AICh3א$+אk*نVN אh3 DKIدאS$\و0sمو$D53$ !XH,2343N' .א\^لUF@!sאQ5Di,3g]KIא$ h'عא$Q$NP>5P،:! I\وn \r lzTא53'دو%'3 $aאNP>K،'د%'3$03aאP3a7!@ C# DirectoryInfo dir1 = new DirectoryInfo(@"C:\Ahmed\Test"); dir1.Create(); ﻛﻮد 282 VB Dim dir1 As New DirectoryInfo("C:\Ahmed\Test") dir1.Create() ﻛﻮد :$¡ אKIدאhO\ًאאض!אMQאNP> C# FileInfo[] imageFiles = dir.GetFiles(); ﻛﻮد VB Dim imageFiles As FileInfo() = dir.GetFiles() ﻛﻮد ^ ًضF! ،$¡7\אh3'\!אnD't אFileSystemInfo *jVIאم$+ אNP> :$¡אzT¢QH C# Console.WriteLine(dir1.CreationTime); ﻛﻮد VB Console.WriteLine(dir1.CreationTime) ﻛﻮد @N9،g 53 وGIF a7!VNאhO\אضא9ً ^3،a7!Y3'ع53hO3 אאضNP>وC .gD FileSsystemInfo *jVI15P> وFileInfo 'ع532Nאنא ﻛﻮد C# using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication7 { class Program { static void Main(string[] args) { DirectoryInfo dir1 = new DirectoryInfo(@"C:\Users\Ahmed\Documents\Visual Studio 2008\WebSites\WebSite4"); 283 FileInfo[] imageFiles = dir1.GetFiles("*.gif"); foreach (FileInfo f in imageFiles) { Console.WriteLine("Name: {0} - Creation Date: {1} . \n\n", f.Name, f.CreationTime); } Console.ReadKey(); } } } ﻛﻮد VB Imports System Imports System.Collections.Generic Imports System.Linq Imports System.Text Imports System.IO Namespace ConsoleApplication7 Class Program Private Shared Sub Main(ByVal args As String()) Dim dir1 As New DirectoryInfo("C:\Users\Ahmed\Documents\Visual Studio 2008\WebSites\WebSite4") Dim imageFiles As FileInfo() = dir1.GetFiles("*.gif") For Each f As FileInfo In imageFiles Console.WriteLine("Name: {0} - Creation Date: {1} . " & Chr(10) & "" & Chr(10) & "", f.Name, f.CreationTime) Next Console.ReadKey() End Sub End Class End Namespace :ً ^3אKPT'نP2Nא 284 Directoryاﻟﺘﻌﺎﻣﻞ ﻣﻊ اﻟﻔﺌﺔ .4 ً%)'نP5K7\אU وFileSystemInfoJO لאI53\* אjVא$7Oa7!،$Q$%z,9 fWLאFً ^3אKPTi,3JOאnDKFאNP>אW،KFz$ אK.+oQ C# System.IO.Directory.Delete(@"C:\ahmed"); ﻛﻮد VB System.IO.Directory.Delete("C:\ahmed") ﻛﻮد DriveInfo اﻟﺘﻌﺎﻣﻞ ﻣﻊ اﻟﻔﺌﺔ .5 X53i,3אא\^لWS،gNDh3'\!א3و¤زg%U Drivers אאضאلJOאlWS :Pro.CSharp 2008 C# Console.WriteLine("***** Fun with DriveInfo *****\n"); // Get info regarding all drives. DriveInfo[] myDrives = DriveInfo.GetDrives(); // Now print drive stats. ﻛﻮد 285 foreach(DriveInfo d in myDrives) { Console.WriteLine("Name: {0}", d.Name); Console.WriteLine("Type: {0}", d.DriveType); // Check to see whether the drive is mounted. if (d.IsReady) { Console.WriteLine("Free space: {0}", d.TotalFreeSpace); Console.WriteLine("Format: {0}", d.DriveFormat); Console.WriteLine("Label: {0}", d.VolumeLabel); Console.WriteLine(); } } Console.ReadLine(); VB Console.WriteLine("***** Fun with DriveInfo *****" & Chr(10) & "") ' Get info regarding all drives. Dim myDrives As DriveInfo() = DriveInfo.GetDrives() ' Now print drive stats. For Each d As DriveInfo In myDrives Console.WriteLine("Name: {0}", d.Name) Console.WriteLine("Type: {0}", d.DriveType) ' Check to see whether the drive is mounted. If d.IsReady Then Console.WriteLine("Free space: {0}", d.TotalFreeSpace) Console.WriteLine("Format: {0}", d.DriveFormat) Console.WriteLine("Label: {0}", d.VolumeLabel) Console.WriteLine() End If Next Console.ReadLine() ﻛﻮد FileInfo اﻟﺘﻌﺎﻣﻞ ﻣﻊ .6 : - Q*אدjV+01 !sא−JOאlWSUjوאلא$א ob'א א$אوאbא o\אUP StreamWritter zTא AppendText() 286 o\א¢ CopyTo() FileStream5jiدDوאo3zTא Create() o\אUP StreamWriter zTא CreateText() o\אfW Delete() $¡!א א3 Directory $¡אH3!3 DirectoryName o\!` א3 Length 'ل7N\אoF$Q$%א$Q$NP>،K7Nא MoveTo() o\א א Name :! IوPوאizא7אP3א03o\!א Open() a7!izא7o\!א OpenRead() StreamReaderאم$+o\!א OpenText() a7!Po\!א OpenWrite() nDfN.وسH$אlWS53 9z%Uً VOgDfNt وאStreamReader 'אصI5Dًא$ .*jVא. : Create אم$+ً ^3 o3zT9 C# FileInfo f = new FileInfo(@"C:\Test.txt"); FileStream fs = f.Create(); ﻛﻮد VB Dim f As New FileInfo("C:\Test.txt") Dim fs As FileStream = f.Create() ﻛﻮد bאa7!،F FileSystemInfo Ui'د%'\*אjVא53Cאم$+אP3 نC@N9ً o\ذאنא$Q$ k I53NP>،KbOi$DKFT3ًD'ibISAttributes .א...a7!izא7،S&אمO ؟9مCOo\אKS!\ً ^3 287 C# if ((File.GetAttributes(path) & FileAttributes.Hidden) == FileAttributes.Hidden) { } ﻛﻮد ﻛﻮد VB If (File.GetAttributes(path) And FileAttributes.Hidden) = FileAttributes.Hidden Then End If :ً ^3אKPT OR K3\مא$+o\אzOI93C C# File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden); ﻛﻮد VB File.SetAttributes(path, File.GetAttributes(path) Or FileAttributes.Hidden) ﻛﻮد Open اﻧﺸﺎء وﻓﺘﺢ اﻟﻤﻠﻔﺎت ﺑﺎﺳﺘﺨﺪام .6.1 : א$O3S وFileMode.OpenOrCreatebא03 Open א$مא$+Nא$`'د אPאU :lzT.l${_'،:RO.o\אh$%'و C# FileInfo f2 = new FileInfo(@"C:\Test2.txt"); FileStream fs2 = f2.Open(FileMode.OpenOrCreate,FileAccess.ReadWrite, FileShare.None); ﻛﻮد VB Dim f2 As New FileInfo("C:\Test2.txt") Dim fs2 As FileStream = f2.Open(FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None) ﻛﻮد 288 :hO\אzTوאOًMQCAICh9¤NS ob'א Lא IOException]1IKF.:$%'و،i,3$Q$%o3]Tא CreateNew 'د%'\!'قאlzT.:$%و'وo3zT. Create FileNotFoundException]1IKF.l${_'وo\א!א Open 'د ًא%'35PQ_ 'l]TوאC'د%'3'نo\!א OpenOrCreate :Q') !3وאo\א!א Truncate ً'دא%'3o\ א5PQ_'،PאFDz$lIK7وאo\אO. Append Ug(9Sً3'FD،:وC53Pz$وא$Q$%$وאO. OpenWriteUa7! وOpen אم$+Oא : enum אאلWSUD'Fh9E : ً MQ אFileAccess אل C# public enum FileAccess { Read, Write, ReadWrite } ﻛﻮد VB public enum FileShare { None, Read, Write, ReadWrite } ﻛﻮد 289 .6.2 وOpenRead ﻓﺘﺢ واﻧﺸﺎء اﻟﻤﻠﻔﺎت ﺑﺎﺳﺘﺨﺪام OpenWrite .hFא53a7!$'عوאNً33'نPאא$D ،3K^3 OpenText ﻓﺘﺢ اﻟﻤﻠﻔﺎت ﺑﺎﺳﺘﺨﺪام .6.3 :ً ^3אKPT، FileStream@ وStreamReader 'ع53'نPiא\دF7'אنאS$'قאHOא C# FileInfo f5 = new FileInfo(@"C:\boot.ini"); StreamReader sreader = f5.OpenText(); ﻛﻮد VB Dim f5 As New FileInfo("C:\boot.ini") Dim sreader As StreamReader = f5.OpenText() ﻛﻮد AppendText وCreateText اﻟﻔﺘﺢ ﺑﺎﺳﺘﺨﺪام .6.4 . StreamWritter'ع53'نPi א\دF7אنא5P>a7!قHOא،7אK^3 File اﻟﺘﻌﺎﻣﻞ ﻣﻊ اﻟﻔﺌﺔ .7 KFאNP>K Static gً(אgN3+oQnDًא4'نP 5،hא$¡אUذ3@O .i,3gD :SP وאizא7אhFJOאUi$Q$%AICدوאل¤NS ob'א א$א array of bytesKP,nDhאizא. ReadAllBytes() 19א53!'OV3 KP,nDhאizא. ReadAllLines() 290 i$وאhא0Bizא. ReadAllText() byte by byte WriteAllBytes() 1 אKP,nDPא WriteAllLines() i$وאPPא WriteAllText() : ProCSharp 2008X53−ً ^3אKPTg3א$+א5P>و C# string[] myTasks = { "Fix bathroom sink", "Call Dave", "Call Mom and Dad", "Play Xbox 360"}; // Write out all data to file on C drive. File.WriteAllLines(@"C:\tasks.txt", myTasks); // Read it all back and print out. foreach (string task in File.ReadAllLines(@"C:\tasks.txt")) { Console.WriteLine("TODO: {0}", task); } ﻛﻮد ﻛﻮد VB Dim myTasks As String() = {"Fix bathroom sink", "Call Dave", "Call Mom and Dad", "Play Xbox 360"} ' Write out all data to file on C drive. File.WriteAllLines("C:\tasks.txt", myTasks) ' Read it all back and print out. For Each task As String In File.ReadAllLines("C:\tasks.txt") Console.WriteLine("TODO: {0}", task) Next :ﻣﻌﻠﻮﻣﺔ اﺿﺎﻓﻴﺔ g!W 53نوP3UgOQ'م7 אنIDisposable لimplemented ذאJO5P>، .net U :ً ^3אKPTق1NאאWSجHI C# using (CarClass newCare) { // do operations } ﻛﻮد 291 VB Using newCare As CarClass ' do operations End Using ﻛﻮد :ً ^3 אKPTiאWאU73n79nhO\א03ًMQאg3א$+ولאRNאW C# FileInfo f = new FileInfo(@"C:\test.txt"); using(StreamReader reader = f.OpenText()) { // code here } ﻛﻮد VB Dim f As New FileInfo("C:\test.txt") Using reader As StreamReader = f.OpenText() ' code here End Using ﻛﻮد Stream .8 nD5Qزg%YאوYO3Yن ذz'אK73وH$V3Y3hאK7!אو$:$V7Q Stream אل o\אQgnsequance of bytesKP,nDGqאU hאK7Q،:! IوCوCPTא .hوאC '،ً79gJ!G03K3NtאمאJOא4t وאSystem.IO.Stream JOא¤NS، .net U : אj*אjVوאلوא$ אnDJOאlWS ob'א א$وאCbא K7 lWS Stream אلFD ! ذא3 *jVI CanRead, CanWrite S وizא7وאCPאFD 292 :! IوhO353gQ3KوFא قא Close() _'، Buffer Uًi'د%'\אhK7\אhQ$ Flush() z,]'م79 א$אlWg! Buffer 'د%وD$F אlWS5PQ 0.א'אU Q stream `אل$bI Length stream אلUنP\دא$ Position bytes53D'FאوQizא. Read(), ReadByte() streamאאلWSU$Q$%نP3U ,p\א0sو Seek() L אstream 'لאل$Q$ SetLength() bytesאل53D'FאوQ Write(), WriteByte() File Stream اﻟﻔﺌﺔ .8.1 03 streaming אل03 K3 a7! *§ אabstract class Q$D7 אJO א1 t אJO אlWS .hO\א جa7!P אK.−'P\אhאizא.53وo\א5353Ci$DUPאs'Qא\^ل א .i'1אlWS@N9אW bytes אKQ'R C# private void filestreamexample(string msg, string beforeendmsg) { using(FileStream f1 = File.Open(@"C:\test.txt", FileMode.Create)) { byte[] msgArray = Encoding.Default.GetBytes(msg); byte[] beforeendmsgArray = Encoding.Default.GetBytes(beforeendmsg); f1.Seek(0, SeekOrigin.Begin); f1.Write(msgArray , 0, msgArray.Length); f1.Position = f1.Lenght-10; f1.Write(beforeendmsgArray , 0, msgAsByteArray.Length); // view total message. long totalLenght=msgArray.Length + msgAsByteArray.Length; byte[] filemsg = new byte[totalLenght]; ﻛﻮد 293 for (int i = 0; i < totalLenght; i++) filemsg[i] = (byte)f1.ReadByte(); Console.WriteLine(Encoding.Default.GetString(filemsg)); } } ﻛﻮد VB Private Sub filestreamexample(ByVal msg As String, ByVal beforeendmsg As String) Using f1 As FileStream = File.Open("C:\test.txt", FileMode.Create) Dim msgArray As Byte() = Encoding.[Default].GetBytes(msg) Dim beforeendmsgArray As Byte() = Encoding.[Default].GetBytes(beforeendmsg) f1.Seek(0, SeekOrigin.Begin); f1.Write(msgArray, 0, msgArray.Length) f1.Position = f1.Lenght - 10 f1.Write(beforeendmsgArray, 0, msgAsByteArray.Length) ' view total message. Dim totalLenght As Long = msgArray.Length + msgAsByteArray.Length Dim filemsg As Byte() = New Byte(totalLenght - 1) {} For i As Integer = 0 To totalLenght - 1 filemsg(i) = CByte(f1.ReadByte()) Next Console.WriteLine(Encoding.[Default].GetString(filemsg)) End Using End Sub اﻟﺘﻌﺎﻣﻞ ﻣﻊ اﻟﻔﺌﺎت اﻟﻤﺸﺘﻘﺔ .8.2 ذstream UPوאizא7א53א'אعi$DNQ$نCאجIلوאIد9'عאs'3UNوHولدCUذ BinaryReader, و StringWriter, StringReaderو StreamWriter, StreamReadergN3 .אنgDfאUC$N3Sو،BinaryWriter 294 StreamWriter, StreamReader .8.3 P אF 9وאل א$ אnD ' ، 7 אE ^ אhJO אY 53 ً 3א$+ وא^ אg, אhJOא : אizא7وא StreamWriter ob'א bوאCא$א א ق Close() bufferאلhQ')!3 Flush() $Q$%1 NewLine QدD Write() $Q$%103 WriteLine() StreamReader :7אi7OאUאوE ^وאلא$!אs9' ob'א bوאCא$א دونLن אPF i,3 אfL אizא. Peek() ,p\نאP3 q izא7א Read() bufferאلUgsאوو$א53D'Fizא. ReadBlock() K31izא. ReadLine() QgNאn,p\نאP353izא. ReadToEnd() :أﻣﺜﻠﺔ :Vo3Pوאizא7אtFD0F® ^ل3 295 C# private void write( string msg) { using(StreamWriter w1 = File.CreateText("test.txt")) { w1.Write("Start"); w1.Write(writer.NewLine); w1.WriteLine(msg); } } private string read() { using (StreamReader s1 = File.OpenText("test.txt")) { string input = null; string msg=""; while ((input = sr.ReadLine()) != null) { Console.WriteLine(input); msg+=input; } return msg; } } ﻛﻮد VB Private Sub write(ByVal msg As String) Using w1 As StreamWriter = File.CreateText("test.txt") w1.Write("Start") w1.Write(writer.NewLine) w1.WriteLine(msg) End Using End Sub Private Function read() As String Using s1 As StreamReader = File.OpenText("test.txt") Dim input As String = Nothing Dim msg As String = "" While (input = sr.ReadLine()) IsNot Nothing Console.WriteLine(input) msg += input End While Return msg ﻛﻮد 296 End Using End Function :o\ אUPאFD2 : ConsoleאلnDizא7אFD2و ﻣﻼﺣﻈﺔ ناتج المتغير النصي سيكون بدون عالمة السطر الجديد والذي سينتج عن الدالة StringWriter, StringReader .8.4 אKPTFD53NP>3'S وstring U'دQ2Nאa7!،FDقH! א$%'Q9ً7ذF :ً ^3 C# StringBuilder stbuilder = strWriter.GetStringBuilder(); stbuilder.Remove(0, 10); stbuilder.Insert(0, "Ahmed Gamal"); ﻛﻮد 297 VB Dim stbuilder As StringBuilder = strWriter.GetStringBuilder() stbuilder.Remove(0, 10) stbuilder.Insert(0, "Ahmed Gamal") BinaryReader, BinaryWriter ﻛﻮد .8.5 nD ' وSystem.ObjectJO א53 7T3 ، binary hO3 U 5Q+ وאizא7 وאP א53 NPe אWS، hQ'['عאG ReadXXXX() א$!אsא.7אhJ!0H9אUi'د%'\وאل א$אGC :JOאlWSאم$+Pوאizא7א\^ل C# FileInfo f = new FileInfo("Binary.dat"); using(BinaryWriter bwriter = new BinaryWriter(f.OpenWrite())) { double dbl = 1234.67; long lng = 34567000; string str = "A, B, C"; // Write differnt data. bwriter.Write(dbl); bwriter.Write(lng); bwriter.Write(str); } // Reading using ReadXXX; using(BinaryReader breader = new BinaryReader(f.OpenRead())) { Console.WriteLine(breader.ReadDouble()); Console.WriteLine(breader.ReadInt64()); // == long as i think , i am not sure. Console.WriteLine(breader.ReadString()); } ﻛﻮد VB Dim f As New FileInfo("Binary.dat") Using bwriter As New BinaryWriter(f.OpenWrite()) Dim dbl As Double = 1234.67 Dim lng As Long = 34567000 Dim str As String = "A, B, C" ' Write differnt data. bwriter.Write(dbl) bwriter.Write(lng) ﻛﻮد 298 bwriter.Write(str) End Using ' Reading using ReadXXX; Using breader As New BinaryReader(f.OpenRead()) Console.WriteLine(breader.ReadDouble()) Console.WriteLine(breader.ReadInt64()) ' == long as i think , i am not sure. Console.WriteLine(breader.ReadString()) End Using FileSystemWatcher .9 h אqא53gD C1Q q!א3وY3o3¤'.א3UNHUًא$%i$O3JO אlWS4 :אh אq א53אG.אQW وאSystem.IO.NotifyFilters enumאلUi'د%'\א C# public enum NotifyFilters { Attributes, CreationTime, DirectoryName, FileName, LastAccess, LastWrite, Security, Size, } ﻛﻮد VB Public Enum NotifyFilters Attributes CreationTime DirectoryName FileName LastAccess LastWrite Security Size End Enum ﻛﻮد א دא،Eא$913SWONQدوאلoQًאH'!جRN،h אq وevents 5D E$RNً}א : אdelegate KP,nD'نPאن$9:! I وqوאKQ$אK^3Eא$אizא7م$+ 299 C# void MyNotificationHandler(object source, FileSystemEventArgs e) { ﻛﻮد } VB Private Sub MyNotificationHandler(ByVal source As Object, ByVal e As FileSystemEventArgs) ﻛﻮد End Sub : אKPT0QنC$99 אqE$3C C# void MyNotificationHandler(object source, RenamedEventArgs e) { ﻛﻮد } VB Private Sub MyNotificationHandler(ByVal source As Object, ByVal e As RenamedEventArgs) ﻛﻮد End Sub $ !234א2jAאنUGNًو،hO\ א.'م}א7Q،دD23oQ'م7Nאن NP3 نwindows Forms U N ' ، ً ^3 q f م$+\ אaqMQ n KFQ 234 אK< אن fWL!وאs9א$L c:\ GVصא7אUVNאhO\!אG.אNאWSN^3U،ًi,3.א\א C# FileSystemWatcher watcher = new FileSystemWatcher(); // monitor files at: watcher.Path = @"c:\"; // monitor files when watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName| NotifyFilters.DirectoryName; // watch files of type watcher.Filter = "*.txt"; // watch events: ﻛﻮد 300 watcher.Created += new FileSystemEventHandler(OnChanged); watcher.Deleted += new FileSystemEventHandler(OnChanged); watcher.EnableRaisingEvents = true; Console.WriteLine("Press 'q' to quit app."); while (Console.Read() != 'q') ; VB Dim watcher As New FileSystemWatcher() ' monitor files at: watcher.Path = "c:\" ' monitor files when watcher.NotifyFilter = NotifyFilters.LastAccess Or NotifyFilters.LastWrite Or NotifyFilters.FileName Or NotifyFilters.DirectoryName ﻛﻮد ' watch files of type watcher.Filter = "*.txt" ' watch events: AddHandler watcher.Created, AddressOf OnChanged AddHandler watcher.Deleted, AddressOf OnChanged watcher.EnableRaisingEvents = True Console.WriteLine("Press 'q' to quit app.") While Console.Read() <> "q"C End While KP * دאV§ 5P> ، OnChanged א$ אzD$ 'م7 N¦! E$ C E$d 3$ND ، (9 F o\ضאD −ً ^3אKPT OnChanged א$אNNP>،^ل3a7!אWS5PGFوCE$ - : qא. ووqوא ﻛﻮد C# static void OnChanged(object source, FileSystemEventArgs e) { Console.WriteLine("File Changed, File Path: {0} , Change: {1}, DateTime: {2}", e.FullPath, e.ChangeType,DateTime.Now.ToString()); } ﻛﻮد VB Private Shared Sub OnChanged(ByVal source As Object, ByVal e As FileSystemEventArgs) Console.WriteLine("File Changed, File Path: {0} , Change: {1}, DateTime: {2}", e.FullPath, e.ChangeType, DateTime.Now.ToString()) End Sub 301 ...234 אX%وאن :( i,3 א53)AICi3:دDאوא53o3fWL0.'3אجiH'Vא Object Serialization .10 . Object Serialization 'مאلgO35DًQسH$אאWSUfN Serialization اﻟﺘﻌﺎﻣﻞ ﻣﻊ ال .10.1 : Serializable ﻋﻤﻞ اﻟﻔﺌﺔ اﻟﺨﺎﺻﺔ ﺑﻚ ﻟﺘﻜﻮن :ً ^3אKPTJOא אnD א: [Serializable] FPא0MنC3אU3K C# [Serializable] public class serial { } ﻛﻮد VB <Serializable()> _ Public Class serial End Class ﻛﻮد 302 ؟Serializable ﻣﺎذا اﺳﺘﻔﻴﺪ ﻣﻦ ﻛﻮن اﻟﻔﺌﺔ اﻟﺨﺎﺻﺔ ﺑﻲ i,\ אP אK^3 *jV א53 iدO Serializable g' 9 אhJO( א3 :אא\^لWS،ً7NFFGVصא7אhO3 C# serial sample =new serial(); using(Stream fs1 = new FileStream("data.txt", FileMode.Create, FileAccess.Write, FileShare.None)) { binFormat.Serialize(fw1, sample ); } ﻛﻮد ﻛﻮد VB Dim sample As New serial() Using fs1 As Stream = New FileStream("data.txt", FileMode.Create, FileAccess.Write, FileShare.None) binFormat.Serialize(fw1, sample) End Using ﻣﺎذا أﻳﻀ ًﺎ ؟ אلgN3، Serializable '9 bאhJOא03K3אK79$.tאhNjPא53 د$D¤NS . ASP.net אلhRObUView State : BinaryFormatter gN3،NjP Serialization KFق1 א53$Q$א¤NS C# BinaryFormatter binFormatter = new BinaryFormatter(); using(Stream fs1 = new FileStream("data.txt", FileMode.Create, FileAccess.Write, FileShare.None)) { binFormat.Serialize(fs1, myobject); } ﻛﻮد ﻛﻮد VB Dim binFormatter As New BinaryFormatter() Using fs1 As Stream = New FileStream("data.txt", FileMode.Create, FileAccess.Write, FileShare.None) 303 binFormat.Serialize(fs1, myobject) End Using : Deserializing KFو C# BinaryFormatter binFormatter = new BinaryFormatter(); using(Stream fs1 = File.OpenRead("data.txt")) { newobject car = (objectclass)binFormatter.Deserialize(fs1); } ﻛﻮد VB Dim binFormatter As New BinaryFormatter() Using fs1 As Stream = File.OpenRead("data.txt") Dim car As newobject = DirectCast(binFormatter.Deserialize(fs1), objectclass) End Using XmlSerializer ﻛﻮد .10.2 53hא$D'א.hP3אY0F® : ( ًאh א5Q§_DUE$'عאN אXML אل$Q KPT XML o33אqVא،VNאhO\אUFg3K3'אgY 0F®و:! IوRא :א ﻛﻮد <root> <Member> <Name>AHmed</Name> <Age>22</Age> </Member> </root> .AttributenF Age وName 3C Element nF22و$"C :NS 53z$אNP> XML 'ل$Q\\!א رابط http://www.w3schools.com/xml/xml_whatis.asp 304 : System.Xml.Serialization اﻟﻌﻨﺎﺻﺮ اﻷﺳﺎﺳﻴﺔ اﻟﻤﻮﺟﻮدة ﻓﻲ ob'א VNא Attribute:אnDVNאאWSKQ'Q XmlAttributeAttribute Element:אnDVNאאWSKQ'Q XmlElementAttribute Rootאل$Q$R XmlRootAttribute XML Text لgQ'Q XmlTextAttribute : Serialization FDQ 5D XML JOאlWSKQ'Rً ^F! C# class Members { [XmlAttribute] string Name; [XmlAttribute] int Age; } ﻛﻮد VB Class Members <XmlAttribute()> _ Private Name As String ﻛﻮد <XmlAttribute()> _ Private Age As Integer End Class o3KP, nD2Nא$` SerializationKFD53وJOאlWSnDhא53!א'عs א$وאن .אXML 305 اﻟﺒﺎب 14 ﺑﺮﻣﺠﺔ اﻟﻨﻮاﻓﺬ ﻓﻲ .net 2008 306 307 ﻣﻘﺪﻣﺔ .1 hg%وאFVKT\RאKLאS4אhqGא03 3 ز3Rbאt אViusal FPא4 303،'دPg%وאHnD4'نPN Visual 4אhqK.3 VDU،م$+FN3 .FVאA'3ضOµ!אsאWONא.وU I]'وb53 ذ:NQ ¤NS،N3g%وאFV:ج3Kم$7 System.Windows.Forms P\אhz% .net U 3אوא53D'F لI533'אzOiدQز53NPe GDI+ f API دوאلD'FًMQC Windows Presentation N7 !'وPQ3 N hz% .net 3.0 03 ًא وIC ،D 2 h3' VV+\א 0O3 $L 4 אh71 5Fs h3' אizO 53 $Q WPF ًאHVI אf 3 אوFoundation . ًא$% ﺑﺎﻟﻜﻮدWindows Forms ﺑﻨﺎء .2 'م7אنKMOQ، Visual Studio 5Fs!'وPQ3Ng!وtאiS אh\אمא$+C$نCK. . Windows Forms KFDOg!01ngNDًא$ 'ذجzNوR} U C$N 53 و، WindowsForms.cs ً ^3 o3 zT . ، Notepad iPO\ אO . אW .'دPא :ً ^3אKPT Forms JOא537T3J!oQ'م7Nً9وC C# class SimpleWindow : Form { } ﻛﻮد VB Class SimpleWindow Inherits Form End Class ﻛﻮد אW، System.Windows.FormshP3!sאnN9، :N3+zD$ Main E$U'م7Nوאن : אKPTK3P'دP'نאP 308 C# using System; using System.Windows.Forms; namespace WindowsForms { class Program { static void Main() { Application.Run(new SimpleWindow ()); } } } class SimpleWindow : Form { } ﻛﻮد VB Imports System Imports System.Windows.Forms Namespace WindowsForms Class Program Private Shared Sub Main() Application.Run(New SimpleWindow()) End Sub End Class End Namespace Class SimpleWindow Inherits Form End Class ﻛﻮد :אK^33C و، אصCmd !'SD3Ka7!אن ﻛﻮد csc /target:winexe *.cs ﻣﻼﺣﻈﺔ .'د!`'אلnDKF3$NDcsc53ً9$vbcم$+א 309 ً J,2N'نאP،نP3CUאم$+ iS%'نP csc oQ$و،234 אH\XSWא$ً :אWSK^3 WONnوC*jVא53 א.... !OTא.'لوאض1אK^3،*jVאUPRאNP3وאن :ً ^3אKPT Object Browser لI53g'لb'א5P>tא3אوא :אKPTمH'O'ن'دאPאW،:1''ل وאضو1 אqً ^3NP3אن$<אW C# class SimpleForm : Form { public SimpleForm (int height, int width, bool center) { ﻛﻮد 310 Width = width; Height = height; if(center) CenterToScreen(); } } ﻛﻮد VB Class SimpleForm Inherits Form Public Sub New(ByVal height As Integer, ByVal width As Integer, ByVal center As Boolean) Me.Width = width Me.Height = height if center=True Then CenterToScreen() End If End Sub End Class :ً ^3אKPT،JOאhאZ3H QF'م7f' Run UC@N95P C# static void Main() { Application.Run(new MainWindow(200, 300,True)); } ﻛﻮد VB Private Shared Sub Main() Application.Run(New MainWindow(200, 300, [True])) End Sub ﻛﻮد ...ً 7NFF Args لI537 אlWSnD'لVLאP3:@ًאN9 اﺿﺎﻓﺔ أدوات ﺑﺎﻟﻜﻮد .2.1 لI530.ذ 'אQ،مH'OאnDO+\אhאدوא0sوnDאنHو$אz%،'دPمH'O אHNF :א3אوא 311 ob'א bوאCא$א Add() !s9אhF AddRange() fWLאhF 0F\א Remove RemoveAt() Clear() Count nDHא\وh9)و$NDًא$%i$O3b אlWS0.א'אU،hدوא9دא$D hאدوא K${، System.Windows.Forms JO'دא%'3gF`!،g!sאNP>t אhאدوא3C ...gQ¯HnDh'دtאhدوא9א اﺿﺎﻓﺔ اﻟﻘﻮاﺋﻢ .2.2 :Fj7אU Exit HزnDaqM אوج5P>אKPT'لb'ولאRN :Fj7אbN ToolStripMenuItem53وFj7 MenuStrip oQ'م7N،ً1'نP'دPא C# private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; ﻛﻮد VB Private menuStrip1 As System.Windows.Forms.MenuStrip Private fileToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem Private exitToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem ﻛﻮد 312 i,3'אد9א0sو53ً9$، BuildForm g א5P وConstructor אلUدאKFDS^אi'1א . Constructor אلU C# public SimpleForm() { Text="Example. Simple Form"; BuildForm(); } ﻛﻮد VB Public Sub New() Text = "Example. Simple Form" BuildForm() End Sub ﻛﻮد :j אFj7 Add אم$+gOMوbNzא0s''م7N،א$אlWS4 'م7Nאن C# fileToolStripMenuItem.Text = "&File"; menuStrip1.Items.Add(mnuFile); exitToolStripMenuItem.Text = "E&xit"; menuStrip1.DropDownItems.Add(mnuFileExit); ﻛﻮد VB fileToolStripMenuItem.Text = "File" menuStrip1.Items.Add(mnuFile) exitToolStripMenuItem.Text = "Exit" menuStrip1.DropDownItems.Add(mnuFileExit) ﻛﻮد :אKPT Exit VNaqMאE$L Handler !sאS^אi'1א C# exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); ﻛﻮد VB ﻛﻮد 313 AddHandler exitToolStripMenuItem.Click, AddressOf exitToolStripMenuItem_Click :مH'Og!sא$אKPT Form لbאFj7'نאPjאFj7א$FNً אIC C# Controls.Add(this.mnuMainMenu); MainMenuStrip = this.menuStrip1; ﻛﻮد VB Controls.Add(Me.mnuMainMenu) MainMenuStrip = Me.menuStrip1 ﻛﻮد : Exit HزnDaqMאصE$LאP'م7f'אن C# private void exitToolStripMenuItem_Click(object sender, EventArgs e) { Application.Exit(); } ﻛﻮد VB Private Sub exitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Application.[Exit]() End Sub ﻛﻮد :אKPTB9'دאP'ن אPQאWg C# class SimpleForm: Form { private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; public SimpleForm() { Text="Example. Simple Form"; BuildForm(); } private void BuildForm() ﻛﻮد 314 { fileToolStripMenuItem.Text = "File"; menuStrip1.Items.Add(mnuFile); exitToolStripMenuItem.Text = "Exit"; menuStrip1.DropDownItems.Add(mnuFileExit); exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); Controls.Add(this.mnuMainMenu); MainMenuStrip = this.menuStrip1; } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { Application.Exit(); } } ﻛﻮد VB Class SimpleForm Inherits Form Private menuStrip1 As System.Windows.Forms.MenuStrip Private fileToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem Private exitToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem Public Sub New() Text = "Example. Simple Form" BuildForm() End Sub Private Sub BuildForm() fileToolStripMenuItem.Text = "&File" menuStrip1.Items.Add(mnuFile) exitToolStripMenuItem.Text = "E&xit" menuStrip1.DropDownItems.Add(mnuFileExit) AddHandler exitToolStripMenuItem.Click, AddressOf exitToolStripMenuItem_Click Controls.Add(Me.mnuMainMenu) MainMenuStrip = Me.menuStrip1 End Sub Private Sub exitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Application.[Exit]() End Sub End Class 315 Viusal Studio.net اﻧﺸﺎء ﻓﻮرم ﻋﻦ ﻃﺮﻳﻖ .3 :Windows Forms ApplicationHI. File-New Fj.53،Visual Studio 2008!אa7! :אKPTא$`، MenuStrip ZI אTool Box אFj7א53אن 316 ًאS%3 א$` Exit VN אnD Y3 aqM א$ND ، Fj7 אFV و$Q F عO . ! Fאن و :אKPTP .X% وF5 nDaqsא53و،'دPאGאنא ....^ ًאKgCbC0s'نאC3O9C . ﺳﻨﺘﻌﺮف ﻋﻠﻰ ﻣﺤﺘﻮﻳﺎت اﻟﻮاﺟﻬﺔ اﻟﺮﺋﻴﺴﻴﺔ، اﻵن nDfאKb'אNאن، Visual Studiog% وאUط7N אnDN!وسH$א5373U .3' אg%'אbطא7Nא : ToolBox . View - ToolBox 53lHg&אNNP>ًאS&5PQ_'، gجאtאjאhאدوאnD'd !sאNP3زאل3ذ03، All Windows Forms GQ'אi'د%'3gجtאhدوא9אSC WאVNאHI وאChoose Item 53 وAdd Tab Q5D،:AIChدوאC!sوא$Q$%GQ' ::!G 317 : Tabs Group nDaqMאNP>F .gNK7NאNP>، gRO F.tאHدV\ وאhO\א0BnD'd :ً ^3אKPT'O\אh,TאYKQ$Ctrl+Tab : Properties Windows 318 $*אjVIs'iH'VאlWS،مH'OאnDl$Q$QVNDgQ$ UGt*אjVאg!${ . Fj7אbND : Solution Explorer . Resources وH'bn אوClasses hJ!وC Forms W!'א53 DوT3hQ')OV53NP> : Class View 319 .:! IوkودوאgVjVI وQ$i'د%'\אhJOאאضא ﻓﻲ اﻧﺸﺎء اﻟﻨﻤﺎذج ؟Visual Studio.net ﻛﻴﻒ ﻳﻌﻤﻞ ال :hO3 Solution ExplorerFj.53Q$$`،'دPSNFtא7Q1@ אON : Form1.cs -1 אWSUgPF.tא'אدא${ًMQ[ אDesign] 0s' אQ5DًQو$QمH'OאUPRא53NPF אnDY3aqMאوא،Q'אFj7א53K7NYs'אYKQ$Y4\ א53 ^'م7Q،o\א 5>א\وسאHمH'O אnDaqMאQ5D^37Q1ذKFDNP>.g'دאصPאOiאدא . Class DiagramnوC Design - Code 0s'אHIوא : Form1.Designer.cs -2 USN3$+אtאg,ًא'אدא$`:ROF.'،مH'O وאhאدوאzTb'אدא9א${NS :سH$אאWS 53אولzא 320 : Form1.rex -3 .:! Iو3$+\אHدV\אnD'd : Windows.Forms ﻣﺠﺎل اﻷﺳﻤﺎء .4 Windows.Forms اﻟﻔﺌﺎت اﻟﺮﺋﻴﺴﻴﺔ ﻟﻌﻨﺎﺻﺮ .4.1 :אhJOא53T3'Sو،JOאlWSU9 אVN'אSمH'Oא System.Object .net hNjKP9אVNא System.MarshalByRefObject مH'O אbyref 'لb'א535PFN System.ComponentModel.Component IcomponentnF\ אInterface אل53T3 321 System.Windows.Forms.Control .ً 79KVO:وNN System.Windows.Forms.ScrollableControl .b אlWg 0FQ אن5P> gN3 T3 VND א، Scrolls אم אل$+ אK% א53 System.Windows.Forms.ContainerControl nD:Iא$ 'dאن5P>gN3T3VNDא،AIC Controls nD'dאن5P>:%K% א53 .AICbND System.Windows.Forms.Form .ً 79KVO:وNN * ودوאلjVI 0B א !¦نW ، System.Windows.Forms.Form JO א53 T3 Form ن אلC ذ ... אنgDfN3Sو، :K7NJOאlWSEא$Cو Form ﺧﺼﺎﺋﺺ اﻟﻔﺌﺔ .4.2 ob'א bא nDم$+\ אaqs$NDl3وאCWONQWאHא$Q$ AcceptButton Enter aTNא5א$Q$R אWSQ،zNCمH'O'نPQ3$ND ActiveMDIChild AICh3H'O5s مH'OאאWSK%P3א$Q$R IsMDIChildIsMDIContainer XML Text لgQ'Q CancelButton م$+\ אaqMQ 3$ND l3وאC WON Q W אH א$Q$ EscHزnD 9مC Control Box مH'OKS$Q$ ControlBox مH'Oودא$KP,$Q$ FormBorderStyle مH'O jאFj7א$Q$ Menu AICi$وא$`،9مC qV وאPאHضزD MaximizeBox OאaQTאU:sوHضزMinimize 322 9مCوز$NQ'OאaQT אUאض$Q$ ShowInTaskbar Q i3 ولlH'g& $ND مH'O Qא$ א17 $Q$ StartPosition nF\ אenumeration ~ ل אI 53 SHIא FormStartPosition אل53 SHI אQ tم وאH'O א$Q$ WindowState FormWindowStatenF\אenumeration : ﻋﻠﻰ اﻟﻌﻨﺎﺻﺮ اﻟﺘﺎﻟﻴﺔFormStartPosition اﻟﻤﺴﻤﻰenumeration وﻳﺤﺘﻮي اﻟـ : ﻓﻴﺤﺘﻮي ﻋﻠﻰFormWindowState أﻣﺎ Form دوال اﻟﻔﺌﺔ .4.3 ob'א א$א مH'OאaTN Activate() مH'Oא قא Close() ,TאoVN3 UمH'Oא0sو CenterToScreen() S'د%وUzNאh,TضאD(م$Q$ LayoutMDI() $ 9 gOI \ 'ع% א5P> 9 r Dialog iH'V مH'Oض אD ShowDialog() g. א 323 Form أﺣﺪاث اﻟﻔﺌﺔ .4.4 ob'א E$Lא 'م7Q3$ND אوActivate 3]zم'אH'OאaTNQ3$NDE$LאאWS1NQ Activated :P31nD1TNאiW!Nא:´م$+\א א قE$C$Q3$ND Closing א قE$gNQ3$ND Closed مH'O אIz,PRאGSWQ3$ND Deactivate Load nD مH'O אH'g& K. E$Lא אWS 1NQ 5P و، مH'O אKF Q 3$ND: -ً D',z1I^ אC53$وאGN`−ً bC,Tא S'د% وUzNאh,Tא53$وא$Q$$ND MDIChildActive .NSgsNtوאg!אP0FQ'g!אWو، Control JOא53T3 مH'O!¦نא،ً7ًMQذאF Control اﻟﻔﺌﺔ .5 Controls ﺧﺼﺎﺋﺺ اﻟﻔﺌﺔ .5.1 ob'א bא O'نא BackColor Iא$*אN'نא ForeColor iH'bOI BackgroundImage :! Iو:D'و:F`وaא Font مH'OوאCi!'قאدאH' א$NDg(QWא,p\'عא Cursor Fg3مH'OאnDhدوא9نאP3 ^t وאDock אلbI03K3 Anchor مH'O `אq 324 gQ')G i دאj7` AutoSize X 'א$Lא53مH'Oאوאiدא9א0s'3 Top X Qא$Lא53مH'Oאوאiدא9א0s'3 Left X KOא$L א53مH'Oאوאiدא9א0s'3 Bottom X 5>א$Lא53مH'Oאوאiدא9א0s'3 Right ود$Lא Bounds 0353 ClientRectangle 'ل1א Height אض Width :3$D53مH'OאوאiدאPRאP3א$Q$ Enabled zOI9وאH'g(א Visible Shift وCtrl وAlt אلK^3 ModifierKeys אلizא. ModifierKeys (oVN\–אQא−5>C) א\وس53'طqM\אH!א3 MouseButtons TabH ز1'אgNل7 bNאGد$ TabIndex TabH لزI53VN'لb'א0N3 TabStop 1و0Y3!OT א%Hد Opacity iدא9אKI*א\وضدאNא Text nD ًאHد. VN ن אU Iא$ אh'ل دאوאb' א53 NPe Controls :IدאbNDXא Controls أﺣﺪاث اﻟﻔﺌﺔ .5.2 ob'א E$Lא \وسaqMא Click \وسY1qs DoubleClick iقאدא1'لא\وسIد MouseEnter iدא9قא153وجא\وسI MouseLeave KO9 א\وسHزaqs MouseDown א\وسHز1qs5D0b9א0!H MouseUp 325 .MouseHover17א\وس !'قH'D MouseMove WheelאلnDaqM MouseWheel دH'Pא53Hزaqs KeyPress 'طqM\אHא5D0b9א0!H KeyUp KOHאaqs KeyDown Lאiدא9!'قאiאدאGR DragDrop AICi¡لאدאi'لאدאIد DragEnter وجI DragLeave i!'قאدאH'D DragOver אE$ Paint System.Windows.Forms.Control أدوات .6 537T3hאدوאKنCSg!3D17ولC،h'مאض אدوא7NN¦سאH$אUذ .i,3سאH$אUgTNF.tאEא$* وאjV0FiدאC C א!¦نW Controls JOא .NQ$jאhض אدوאNאن Button .6.1 :K^3*jVאnD'd،ًא$%دD3CHز .3אH زg(3$Q$:FlatStyle .3אHز53*Nא0s'3:TextAlign 326 CheckBox .6.2 :K^3!s* אjVInD'd،bNDi$DHIאNNP>،د$\אHI9אHز .HI9 א:CheckState .( ً j%KO3−KO3 −KO3)^bI KFd:'$Q$R :ThreeState RadioButton .6.3 panel U gN3 K 0s i3 53^ :3א$+ א$Q N' ، $ وאHI FQ :NP א وK^3 .o ListBox وComboBox .6.4 327 .X'1\`אLאG^ وא$وאobUو9א،hאHI5Fs53HI Fj. .... Items.Remove وItems.Add K^3 Collection.List USNFt*אjVא0BnD'd Textbox .6.5 : !s9אgVjVI،gIدאPم$+FFViدאC .a7!izא7g% :ReadOnly .لI* دNא03K%Ug(QWא3 א:PasswordChar .1אiد$3 g´vF א:MultiLine .*NnV.9'لא1 א:maxLength .QFא,א:ScrollsBar .ً ^3دHوو23K^3i!אدא:'bو$*NאfOא:WordWrap HI אNP3 'نP אW ،System.Windows.Forms.ScrollableControl JO א53 7T3 g א . ScrollBars nF\ אenumeration אل530sو : ﺗﻄﺒﻴﻘﺎت ﺳﺮﻳﻌﺔ ﻋﻠﻰ ﻣﺮﺑﻊ اﻟﻨﺼﻮص :ً ^3م.HאA'K7Q9'صVNא03K− C# private void TextBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if ((e.KeyChar < '0' | e.KeyChar > '9')) { e.Handled = true; } } ﻛﻮد 328 VB Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If (e.KeyChar < "0"c Or e.KeyChar > "9"c) Then e.Handled = True End If End Sub ﻛﻮد :*Nא03KIدאF5DRא− C# private void Button1_Click(object sender, System.EventArgs e) { // Rن`אP3אولnD'RW אq\א ﻛﻮد int index; //RאF string SearchWord = "Ahmed"; //iدא ل79א TextBox1.Focus(); //Qא$אUlN!DW אq\אUFPאQא$نP30sو index = TextBox1.Text.IndexOf(SearchWord); // k'1وFPאQא$53$Q$R*אjVIאم$+FPא$Q$ TextBox1.SelectionStart = index; TextBox1.SelectionLength = SearchWord.Length; } VB Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Rن`אP3אولnD'RW אq\א Dim index As Integer 'RאF Dim SearchWord As String= "Ahmed" 'iدא ل79א TextBox1.Focus() 'Qא$אUlN!DW אq\אUFPאQא$نP30sو ﻛﻮد 329 index = TextBox1.Text.IndexOf(SearchWord) ' k'1وFPאQא$53$Q$R*אjVIאم$+FPא$Q$ TextBox1.SelectionStart = index TextBox1.SelectionLength = SearchWord.Length End Sub Label .6.6 .a7!–KQ$. 'صVNض אiدאC Panel وGroupBox .6.7 .gIא$AIChدوאC0sو5P>QوhدوאC RichTextBox .6.8 330 Y قHO' אS TextBox Y وgN قHO א، O h7N nD ' אنgQ'[ F * iدאC .H'bوh7NnD'd0\7אiH'Vא، Wordpad وNotepad :!אs9*אjVאnD' .*NאfOא$Q$R :Wordwrap .1دא$D$Q$R:Lines .و'لQא$17אو،QgوQא$17Q 5D*Nא53z%$Q$R :Select .SelectionColorא'نK^3،د$[אz` aIN$Q$R:SelectionXXX .ل7 .g%ًوj7Z9א5QوND$Q$R:DetectUrls :!אs9وאلא$אnD'd F .Y3H353Vo3 O :LoadFile .Y3نP3Uo\אªOL :SaveFile : أﻣﺜﻠﺔ ﺳﺮﻳﻌﺔ :Io3UªOLא53وVo353*NאiאدאhQ')izא7− C# RichTextBox1.LoadFile("C:\Ahmed.txt", RichTextBoxStreamType.PlainText); RichTextBox1.SaveFile("C:\Ahmed2.txt", RichTextBoxStreamType.PlainText); ﻛﻮد VB RichTextBox1.LoadFile("C:\Ahmed.txt", RichTextBoxStreamType.PlainText) RichTextBox1.SaveFile("C:\Ahmed2.txt", RichTextBoxStreamType.PlainText) ﻛﻮد 'عN אaM 'م7N! rtf 'عN א53 h7N nD 'd V o\و' ن א :ً ^3אKPTRichTextBoxStreamType.RichText C# RichTextBox1.LoadFile("C:\Ahmed.rtf ", RichTextBoxStreamType.RichText); ﻛﻮد 331 RichTextBox1.SaveFile("C:\Ahmed2.rtf ", RichTextBoxStreamType.RichText); VB RichTextBox1.LoadFile("C:\Ahmed.rtf ", RichTextBoxStreamType.RichText) RichTextBox1.SaveFile("C:\Ahmed2.rtf", RichTextBoxStreamType.RichText) ﻛﻮد Rא2jK5Q''م7Ni\אlWS5Pو،*Nאiدא:FDWאR^لא31$Nوאن :AIi$وאS$Q$53ً9$ C# ﻛﻮد int index=0; while((index = richTextBox1.Text.IndexOf(textBox1.Text, index))!=-1) { richTextBox1.Select(index, textBox1.Text.Length); richTextBox1.SelectionColor = System.Drawing.Color.Red; index += textBox1.Text.Length; } MessageBox.Show("hFPא5Q'53zg9;)"א VB Dim index As Integer = 0 While (index = richTextBox1.Text.IndexOf(textBox1.Text, index)) <> -1 richTextBox1.[Select](index, textBox1.Text.Length) richTextBox1.SelectionColor = System.Drawing.Color.Red index += textBox1.Text.Length End While ﻛﻮد MessageBox.Show("hFPא5Q'53zg9)"א :אKPTWONא2'نPو 332 Timer .6.9 :QHאP 3 אوאKFD U $O ، Y3 Interval K lWON Q W وאTicker E$ k ، .pF iدאC .N3قزH'אO aM.ًMQא،i$دلوא3S و1000 IntervalbIaM.،^'אDKFD^ل3 :Tick E$LאU'دאPאP.ًوMQאTrueEnabledbא C# label1.Text = DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second; ﻛﻮد VB label1.Text = DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second ﻛﻮد 333 :אWSK^3ًJ,2N'نאPو TreeView .6.10 .g!WوbNDC!sא: I535P>W وאNodes 'S9אSVND ،i`TאiدאCض :iאدאlWS5Fs:! IوH'b!sאnوNאU qא5P> :אaאא53gND$Q\אnDfאNP> رابط http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.aspx 334 Progressbar .6.11 !s אn وאدnD א$L א$Q$R Minimum - Maximum S 9 א:VjVI ، م$7 א,p3 ض Style b لאI53م$7אF style $Q$NP>،i3Kم$7 אHא$73$Q$R Step b+ . ProgressBarStyle nF\ אenumeration אل53 C7tوא . Value bאمא$+ ً 79bא$Q$5P> Trackbar .6.12 .h'VאOIو0! אصTrackbar K^3،:F7PR53אNP Progressbar K :T3 DateTimePicker .6.13 ¢QH אX' א$Q$R Format b א53 אضX' א$Q$ NP> ، h. وאو¢QH א'אHI9 iدאC $و¢QHnV.א$0sو5P>F Valuebא53א\وض¢QHאnD'لVLא5P>.א\وض .MinDate - MaxDateYbאQ5DnدC 335 0.'3]نאOCאW ... gbOnDfאU.'אDsא53Aو$%9אًو$%i ^hאدوא : iدאCKPًVOً,${!'وPQ3 رابط http://msdn.microsoft.com/en-us/library/aa984065(VS.71).aspx Dialogs .7 'م7N ^ א\ אU ، N صI $ وאFV 9 ً وC 'م7N QH'אL אh\ א5D ND's'3 Qא$ U .jTאQH'אLאh\אh3א$+ אnDf FormBorderStylebI aM . ، resizeable אلbI zq . ، $Q$% مH'! zT . h\אGCFV 'نPQ7Q1אlWg ... MaximizeBox وMinimizeBox zOI.،FixedDialog .QH'אLא bN א53ًא$وא2N'نאPQ Dialog وCH'א03אU،'dFH'אLא0\ אFV.אن :א7אnD'dW وאDialogResultnF\ אenumeration U!\א Abort, Cancel, Ignore, No, None, OK, Retry, Yes .H+\אH אnDمH'O AcceptButton אلbIaM OK F7א$QWאHאaM CancelButton bא$< Cancel b+Na39ًאMQא :ً ^3אKPT ShowDialog 3مא$+ Dialog H'א03iH'VمH'!Hg&9 C# newDialog.ShowDialog(); ﻛﻮد VB newDialog.ShowDialog() ﻛﻮد 336 אKPTN'دאصPאGPN،lHIאH!אز3و:ND{Nא7 אizא7%rNو}א5Pو :א\^لKnD C# if (newDialog.ShowDialog() == DialogResult.Cancel) { // do something } else if (newDialog.ShowDialog() == DialogResult.Ok) { // do something else } ﻛﻮد VB If newDialog.ShowDialog() = DialogResult.Cancel Then ' do something ElseIf newDialog.ShowDialog() = DialogResult.Ok Then ' do something else End If ﻛﻮد KQ$ ً ^3 . אW ، public '1\ א7 אoQ ND ً 3'ن אP Dialog אلhQ') izא. Nو'و : אKPT*Nא03 C# public System.Windows.Forms.TextBox TextBox1; ﻛﻮد VB Public TextBox1 As System.Windows.Forms.TextBox ﻛﻮد MessageBox .7.1 :אKPTaאgH'b، MessageBox QWRאKjH'S Dialogs אل53Kg وאa9'عאNא C# MessageBox.Show("Welcome ..."); ﻛﻮد VB ﻛﻮد 337 MessageBox.Show("Welcome ...") ]PRא، overloads20$` Show א$kHא5P>tאhאZ3H!א3%' :NSgN3 YNضאN،QQWRאjHUKP, :3 QQWHHg&א C# MessageBox.Show("Welcome ...","Title",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); ﻛﻮد VB MessageBox.Show("Welcome ...","Title",MessageBoxButtons.OK,MessageBoxIcon.Exclamation) ﻛﻮد :g(\א : ًsאZ!אgN3$ وאK%03،h9i$DY¤ §QQWHHg&א C# DialogResult reslt = MessageBox.Show("Do you want to save", "Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation,MessageBoxDefaultButton.Button1); if (reslt = DialogResult.Yes) MessageBox.Show("you want to save."); else if (reslt = DialogResult.No) MessageBox.Show("you don't want to save."); else if (reslt = DialogResult.Cancel) MessageBox.Show("you cancel this operation."); ﻛﻮد 338 VB Dim reslt As DialogResult = MessageBox.Show("Do you want to save", "Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) If reslt = DialogResult.Yes Then MessageBox.Show("you want to save.") ElseIf reslt = DialogResult.No Then MessageBox.Show("you don't want to save.") ElseIf reslt = DialogResult.Cancel Then MessageBox.Show("you cancel this operation.") End If ﻛﻮد aאאאWS لI53ًBgsאאNP>،א...i$D3o3Hg& א،AIChאHIאi$D¤NS رابط http://msdn.microsoft.com/en-us/libr...ebox.show.aspx Dialogs Controls .7.2 OnDאنHو$אz%،SzTאONFوQH'אLאh\ א53a'عאNאnDN!אن$ ...hאدوא5Fsi'د%'\אאQH'אLאh\אم א$+א Color Dialog .7.3 :ً ^3iH'VO 'نאqً1 9 ً ^3]אنTNN وToolBox אل53:!s.،א'אنHIא03 339 :א3א:! Gوא3CH وزpicturebox iH'bosC C# if (colorDialog1.ShowDialog() == DialogResult.OK) pictureBox1.BackColor = colorDialog1.Color; else MessageBox.Show("cancel operation"); ﻛﻮد VB If colorDialog1.ShowDialog() = DialogResult.OK Then pictureBox1.BackColor = colorDialog1.Color Else MessageBox.Show("cancel operation") End If ﻛﻮد t وאAllowFullOpen K^3אم$+9אj, gNPאWSH'אLא03U!s9* אjVא¤NS :ً ^3אKPT7'אنא9 אHIא53م$+\א0N301 340 :ً ^3אKPTi,3K3P Sg(t אfullopen bوא :!'وPQ353VOaאH رابط http://msdn.microsoft.com/en-us/library/ms646375.aspx 341 Font Dialog .7.4 :*03aI q^ل3 KF'مאن7N،'ط1אHI9م$+Q C# fontDialog1.ShowColor = true; fontDialog1.Font = textBox1.Font; fontDialog1.Color = textBox1.ForeColor; if (fontDialog1.ShowDialog() == DialogResult.OK) { textBox1.Font = fontDialog1.Font; textBox1.ForeColor = fontDialog1.Color; } ﻛﻮد VB fontDialog1.ShowColor = True fontDialog1.Font = textBox1.Font fontDialog1.Color = textBox1.ForeColor If fontDialog1.ShowDialog() = DialogResult.OK Then textBox1.Font = fontDialog1.Font textBox1.ForeColor = fontDialog1.Color End If ﻛﻮد 342 :!'وPQ353VOaאH رابط http://msdn.microsoft.com/en-us/library/system.windows.forms.fontdialog(VS.80).aspx Open And Save Dialogs .7.5 g(OنP3 $Q$وChO\!אFD$Q$Rg3א$+אQiאدU،QH'אLאh\א53 YD'g,א ::(O 53 و:D KQ$ א، V o3 O : I 53 'م7 a ^ل3 KF 'م7N ، !s 'م75½ אICو،OIوªORHزos، Multiline=True bIK%وאa *03osא .i,3'دP لאI53gOMNK SaveFileDialog وOpenFileDialog :gN3$وאHIא53وVNאhO\א$Q$RH'אLא0\אمא$+ אSNQ$FDولC C# string fileToOpen=""; OpenFileDialog openFile = new OpenFileDialog(); openFile.DefaultExt = "txt"; openFile.Filter = "Word documents (*.txt)|*.txt"; if (openFile.ShowDialog() == DialogResult.OK) fileToOpen = openFile.FileName; ﻛﻮد VB Dim fileToOpen As String = "" Dim openFile As New OpenFileDialog() openFile.DefaultExt = "txt" openFile.Filter = "Word documents (*.txt)|*.txt" If openFile.ShowDialog() = DialogResult.OK Then fileToOpen = openFile.FileName End If ﻛﻮد :ً 7SNF7Q1*03U:Q')0sوF'م7N، q3Uo\ אH3NQ$bאنא C# if (fileToOpen != "") { using (System.IO.StreamReader s1 = ﻛﻮد 343 System.IO.File.OpenText(fileToOpen)) { string input = null; textBox1.Text = ""; while ((input = s1.ReadLine()) != null) { textBox1.Text += input; } } } VB If fileToOpen <> "" Then Using s1 As System.IO.StreamReader = System.IO.File.OpenText(fileToOpen) Dim input As String = Nothing textBox1.Text = "" While (input = s1.ReadLine()) IsNot Nothing textBox1.Text += input End While End Using End If ﻛﻮد :o\אªO:!'دWنאP\א$Q$RªOL אH'א03م$+Nאن C# string fileToSave = ""; SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) fileToSave = saveFileDialog1.FileName; ﻛﻮد VB Dim fileToSave As String = "" Dim saveFileDialog1 As New SaveFileDialog() saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" If saveFileDialog1.ShowDialog() = DialogResult.OK Then fileToSave = saveFileDialog1.FileName End If ﻛﻮد :lHIم$+\مא.WאH\אUVNאo\אªOr'م7 ،ً7NFFو 344 C# if (fileToSave!="") { using (System.IO.StreamWriter w1 = System.IO.File.CreateText(fileToSave)) { w1.WriteLine(textBox1.Text); } } ﻛﻮد VB If fileToSave <> "" Then Using w1 As System.IO.StreamWriter = System.IO.File.CreateText(fileToSave) w1.WriteLine(textBox1.Text) ﻛﻮد End Using End If :אWSK^3ًJ,'نP2Nא :NSFgND$Q\אnD ع9 אNP>،YNjP אP!s9*אjVא¤NS 345 رابط http://msdn.microsoft.com/en-us/library/aa287592(VS.71).aspx http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog.aspx ...Oo353^C$Q$، a7!o\אوאא$¡אאizא.אوhO\א53'ع$Q$NP> .א print Dialog .7.6 :!'وPQ353אaאא¤$OQאن5P> ،D1אFD*jVIUPRم$+Q رابط http://msdn.microsoft.com/en-us/library/system.windows.forms.printdialog.aspx أﺣﺪاث اﻟﻤﺎوس .8 346 Properties 53 MouseDown E$LאGSWN ،א\وس53'طqM\אHً\!א9وC :'دאPאGP53و C# if (e.Button == MouseButtons.Left) MessageBox.Show("Left click"); if (e.Button == MouseButtons.Right) MessageBox.Show("Right click"); if (e.Button == MouseButtons.Middle) MessageBox.Show("Middle click"); ﻛﻮد VB If e.Button = MouseButtons.Left Then MessageBox.Show("Left click") End If If e.Button = MouseButtons.Right Then MessageBox.Show("Right click") End If If e.Button = MouseButtons.Middle Then MessageBox.Show("Middle click") End If ﻛﻮد 347 : MouseMove E$Uً ^3א\وسgD >tא17Nو\!א C# this.Text = "X: " + e.X + ", Y:" + e.Y; ﻛﻮد VB Me.Text = "X: " + e.X + ", Y:" + e.Y ﻛﻮد أﺣﺪاث اﻟﻜﻴﺒﻮرد .9 key_up :E$Uً ^3א3אGP'طqM\אH אصE$Lאizא7 C# this.Text="key: " + e.KeyCode.ToString(); ﻛﻮد VB Me.Text = "key: " + e.KeyCode.ToString() ﻛﻮد U ^ وאkey U אولH א0MN ، L אH א03 ً ^3 'طqM3 I H ز¤NS ذא ن3 !\ 5Pو :אKPTModifier C# this.Text = string.Format("Key: {0} Modifier: {1}",e.KeyCode.ToString(), e.Modifiers.ToString()); ﻛﻮد 348 VB Me.Text = String.Format("Key: {0} Modifier: {1}", e.KeyCode.ToString(), e.Modifiers.ToString()) ﻛﻮد ...gDzNhFאWON وIF אم$+Eא$אizא. P3אن¤HI9Dدא9ً 349 اﻟﺒﺎب GDI+ 15 350 351 GDI+ ﻣﻘﺪﻣﺔ إﻟﻰ .1 مH'O אnDD 2 h3'H K% א53 KM! א9 ً ' !' وSystem.Drawing JO א3 אوאlWS 0 :אjאhJO אnD'،:! Iאوh11+\وא hFDUg3$+tא9شאO موא. אnD'،jאJO א:System.Drawing .1 .א K^3אnD ¤$Dtوאلא$ א53AICD'Fم$7: System.Drawing.Drawing2D .2 geometric transforms وgradient brushes WON وIא$ אh אizא. وH'V אnD FD U ¤$D : System.Drawing.Imaging .3 .O+\אhFא .D1א03K3وאD1H'bh3'HKQ'nD¤$D :System.Drawing.Printing .4 .:! I'طو1א033'HiH'VK3 א:System.Drawing.Tex .5 System.Drawing ﻣﺤﺘﻮﻳﺎت اﻟﻔﺌﺔ .2 :SgQ')SC،ً3א$+ وא^א9אJOאS ob'א VNא iH'Vאh3'3z'א9 Bitmap א'אعi$Dkو،5Q'אFi,! Brush double N7 אم$+ אBuffer א אلWS אم$+ NP> BufferedGraphics buffering 5Q'אوאhFDUg3א$+א5P>tא'אنאSystemColors Color .'صVNאHhFDUg3א$+א5P>t'طא1 אFontFamily Font ً 79gDfN tوא،אhFDU9א5jPא Graphics h'7Q9א03K3אSystemIcons Icon H'VאhFQ3KP abstract class אل Image R\אH'V א03K3 ImageAnimator 352 'אعCi$D:و،אhF. Pen hא$9א03K3 Point K13 Rectangle KPT\אX Size 'صVNאhF Q3KnDJOאlWS' StringFormat . ًא$%i$O3*jVIi$D:و،CلP,9א03K3صI Region : double buffering ، flicker PT3U i$وאi3م$+FlH'g&K73 buffer UلF9 FN7S :NS53gDfא5P>אhN7UiH'gT3N7S'مFאnD رابط http://msdn.microsoft.com/en-us/library/b367a457.aspx :aאאאWS لI53gQ')0B 5D$Q\!א3NP>F رابط http://msdn.microsoft.com/en-us/library/system.drawing.aspx Graphics اﻟﻔﺌﺔ .3 :قi$lzTא5P> ،אFDUא5jP'אS Graphics 5jPא ::! I وpicture box 53'نC$\@אOو،مH'Oא53− C# Graphics myGraphic = Form1.CreateGraphics(); ﻛﻮد VB Dim myGraphic As Graphics = Form1.CreateGraphics() ﻛﻮد :ً ^3אKPT PaintEventArgs 5jPאQ5D،ً ^3 مH'OiאאدאE$53وC- 353 C# private void Form1_Paint(object sender, PaintEventArgs e) { Graphics myGraphic = e.Graphics(); } ﻛﻮد VB Private Sub Form1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Dim myGraphic As Graphics = e.Graphics() End Sub ﻛﻮد :א3אوאnDJOאlWS'و ob'א VNא ًi'د%'3iH'b53H5jKFD FromHdc() FromHwnd() FromImage() Clear() 5jP אhQ')3 -. $NSKP, אوiH'bH DrawArc() hNRN3gNPوSN3fDC9 Beziers - H DrawBeziers() nNRN3H DrawCurve() وMKP,H DrawEllipse() '7QאH DrawIcon() 73aI H DrawLine() 'ط1א53D'F H DrawLines() a1H DrawPie() H3H DrawPath() K13H DrawRectangle() h 13H DrawRectangles() *H DrawString() وMKP,5Q' FillEllipse() a15Q' FillPie() 354 0M35Q' FillPolygon() 035Q' FillRectangle() H35Q' FillPath() :kودوאJOאlWS'لh3'\ א53$Q\ رابط http://msdn.microsoft.com/en-us/library/system.drawing.graphics_members.aspx g! FillXXX 5Q'دوאلא3C، Pen 7مא$+ DrawXXX دوאلא0BنC(9وאن .9 ً وCYNjPא5QWSnDfC$NאW، Brush i,Oمא$+ Pen .4 NC9،:! Iق وHאز7 Pen.BlueK^3$Q$Q5Di,3אhFDU Pen אم$+ א5P> :ً ^3אKPTiد$\ א:VjVI53iدO9وא:N35joQnD5QHد.Nز3 C# Pen myPen = new Pen(Color.Black, 3); ﻛﻮد VB Dim myPen As New Pen(Color.Black, 3) ﻛﻮد ً ^3$Q$Q5D7*jV א53$Q\אمא$+אNNP>. 3'دوضC'ن.zTNF. :Qא$א17KP, C# myPen.StartCap = LineCap.ArrowAnchor; ﻛﻮد VB myPen.StartCap = LineCap.ArrowAnchor ﻛﻮد :7*אjVI5D$Q\\!א 355 رابط http://msdn.microsoft.com/en-us/library/system.drawing.pen.aspx Brush .5 :אKPT^ل3a]Ob'نאi,!zTא5P>،7Q1@ אON C# SolidBrush myBrush = new SolidBrush (Color.Yellow); ﻛﻮد VB Dim myBrush As New SolidBrush(Color.Yellow) ﻛﻮد :ً ^3אKPT'ن53^]i,!zTًMQא5P> ﻛﻮد C# HatchBrush myBrush =new HatchBrush(HatchStyle.BackwardDiagonal, Color.Green, Color.White); VB Dim myBrush As New HatchBrush(HatchStyle.BackwardDiagonal, Color.Green, Color.White) ﻛﻮد :i,O*אjVI5D$Q\\!א رابط http://msdn.microsoft.com/en-us/library/system.drawing.brush.aspx 356 اﻟﺮﺳﻢ .6 :ً ^3אKPT73aIHUz$אNNP> ،אصNNj]Tאنא$ C# myGraphic.DrawLine(Pens.Blue, 20, 20, 100, 100); ﻛﻮد VB myGraphic.DrawLine(Pens.Blue, 20, 20, 100, 100) ﻛﻮد :K13وC C# myGraphic.DrawRectangle(Pens.Blue, New Rectangle(20, 20, 100, 100)); ﻛﻮد VB myGraphic.DrawRectangle(Pens.Blue, New Rectangle(20, 20, 100, 100)) ﻛﻮد :nNRN3HوC C# myGraphic.DrawBezier(Pens.Blue, 10, 20, 50, 80, 10, 80, 100, 50); ﻛﻮد VB myGraphic.DrawBezier(Pens.Blue, 10, 20, 50, 80, 10, 80, 100, 50) ﻛﻮد :ً ^3אKPTa7N3:] l$Q$و:OQ.5jאم$+5Pو73aIHNP3 C# Graphics myGraphic = e.Graphics; Pen myPen = new Pen(Color.Blue, 3); myPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; myGraphic.DrawLine(myPen, 20, 20, 100, 100); ﻛﻮد VB Dim myGraphic As Graphics = e.Graphics ﻛﻮد 357 Dim myPen As New Pen(Color.Blue, 3) myPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot myGraphic.DrawLine(myPen, 20, 20, 100, 100) :ً ^3^3KP,nD'ط1Ii$D53H3وC C# GraphicsPath myGraphicPath = new GraphicsPath(); myGraphicPath.StartFigure(); myGraphicPath.AddLine(10, 10, 30, 60); myGraphicPath.AddLine(30, 60, 60, 10); myGraphicPath.AddLine(60, 10, 10, 10); myGraphicPath.CloseFigure(); myGraphic.DrawPath(myPen, myGraphicPath); ﻛﻮد VB Dim myGraphicPath As New GraphicsPath() myGraphicPath.StartFigure() myGraphicPath.AddLine(10, 10, 30, 60) myGraphicPath.AddLine(30, 60, 60, 10) myGraphicPath.AddLine(60, 10, 10, 10) myGraphicPath.CloseFigure() myGraphic.DrawPath(myPen, myGraphicPath) ﻛﻮد N\ אi,OאQe03 FillPath 'نP Iא1 אqً'3:وC رﺳﻢ اﻟﻨﺼﻮص .7 و'نz"אi,O* 'دאP'אS:D^ل3aC GDI _אلD53I.'S'صVNאH .200و20017NאU"C ﻛﻮد C# myGraphic.DrawString("Hello GDI+", new Font("Times New Roman", 30), Brushes.Red, 200, 200); ﻛﻮد VB myGraphic.DrawString("Hello GDI+", new Font("Times New Roman", 30), Brushes.Red, 200, 200) 358 iH'VًVً ^3P،אh אq3 :!s وאStringFormat 5jPאمא$+אNP3 VQً79 :Q'دFD ﻛﻮد C# Graphics myGraphic = e.Graphics; StringFormat drawFormat = new StringFormat(); drawFormat.FormatFlags = StringFormatFlags.DirectionVertical; myGraphic.DrawString("Hello GDI+", new Font("Times New Roman", 30), Brushes.Red, 100, 20, drawFormat); VB Dim myGraphic As Graphics = e.Graphics Dim drawFormat As New StringFormat() drawFormat.FormatFlags = StringFormatFlags.DirectionVertical myGraphic.DrawString("Hello GDI+", New Font("Times New Roman", 30), Brushes.Red, 100, 20, drawFormat) ﻛﻮد :אWSK^3ًJ,2N'نאP 'SوaאאאWSnD'د%'3א\^ل،NQ$h3'وسאHدnD ً 71'نP$%س}^لH$אIא : אKPTD 359 :א\^لaאH رابط http://www.java2s.com/Tutorial/CSharp/0480__2D/Clockanimation.htm :N3iאد9אNP>،:!Q1ول אCnDsو901_אcאnTIC GDI _אلDUًא$% ^Pא¤NS .NS53 رابط http://msdn.microsoft.com/en-us/library/ms533798(VS.85).aspx 360 361 اﻟﺒﺎب 16 Windows Presentation Foundation 362 363 ﺗﻌﺮﻳﻔﺎت أﺳﺎﺳﻴﺔ WPF .1 .1.1 53 i$Q$% 3'H N7 S WPF ًאHVI אfQ 3 وC Windows Presentation Foundation Extensible Application fQ 3 nD $F .net framework 3.0 03 hC$ !'وPQ3 U !'وPQ3 hN7 53 $Q$ אK א4 S و، XAML ًאHVI وאMarkup Language Windows Media Player API's وDirectX APIs وGDI+ وWindows Forms $j\אhg%א'א .GZאnD'Q$Oو אدوאjNh3'وאhg%'א FV zg وאhg% א'אFV 53 zא$ط א7N אlWS 0F´ PR אP3 b א$7! WPF 03 3C .k I53'Q$Oא^ אدوא XAML .1.2 $، ASP.net hRObUE$dنF^3 3iH'VFV'دوאPאYKVO אXAML f$g (مX.C XAML نאلC –قHOא03 –ROb FV:3$+W אHTML Xg, XAML .א...*jVIوhJ! nD'd4אhq Microsoft Expression .1.3 U،'Q`'אل'دOאU37Q1gOQQ ،h3'אhFD53D'F5DiHDFVنא،ً7 Adobe FlashK^323UAIC7Q1 وphotoshop K^3H'V אQR23UH'bدK(Y Q'1 אJ U gFg! 5P> iH'V h3' א2NQ h3' אU *V+3 23 Q$ אن אنK§ .. ؟bא 364 5Pو،:! Iو¤R\א^وאFVאUVV+323 א4، Expression iP!SlWS .'gO+\א71U:3א$+א5P> XAML KP, nD'نPQنC5P>2Nא . شO:TאوאX',''O:T א3'אgN3وGQ'*V+\אgN323א4אlWS53hאHא$bאi$D¤NS WPF אلnDNFDiZ!¤HDאU234אאWS 0s5Pو،234אאWSv,U0'NNP .: I53:3$+ W אXAML אج5P> .Qא$א53 WPF _אلDz$N'دN،ًא$%Q3$73lWS WPF أﻧﻮاع ﺗﻄﺒﻴﻘﺎت .2 lWS nDfولאRN،KP,53^CnDg(Qאن5P>K،a7!$71 @دWPF 1 .لאنP,א : Traditional Desktop Applications -1 .:! Iوhg%وא'אg(\ אYR7Q دWPF אل، exe $71،ًD',^'عאNא : Navigation-Based -2 وForward Q$OV\*אjVI:Q$5Pد وD1'نP71HI אWPF لI53NP> 1 g'U$Q$%9، pages UCSد$hRObYK7Nمא$+F 5P>Backward .OV¨א$3A'دD : XBAP Applications -3 ، JAVA Applet אلC$}ًא$%:,،OV\ ل אI53KFQ1zN WPF hא53i$Q$%i3 local machine אلU XBAP application KFR'م7Q، URL 'אنND لI53:'لb'אQ .gqT'م7Qو : Silverlight Application -4 X :T אi$Q$, ، i,3 OV\ ل אI 53 g!M אQ h71 zN NP> ً MQ אWPF لI 53 365 g(\אUNhP3 Silverlight אل0FQ،O+\ אZאhRObU'د%'\אembeded flash .z'א$nDWONوא WPF ﻣﺤﺘﻮﻳﺎت اﻟﻔﺌﺔ .3 . WPF KאbN א:System.Windows Tool وאلj'א7אK^371 zN3א زbNא53D'FnD' :System.Windows.Controls .:! IوTips . XAML £bWONوgOb אhJO א:System.Windows.Markup .3D 3VوאR\אH'V'وאQ$Oא03 K3bאhJO א:System.Windows.Media h71 א53 Navigation-Based'عN א03 K3 b אhJO א:System.Windows.Navigation .ً 7lNRsوWא .2D3VאhFhאدوא53D'F :System.Windows.Shapes WPF ﺗﻄﺒﻴﻘﻚ اﻷول ﻓﻲ ﻋﺎﻟﻢ .4 zNOi,3N\אlWS`وزNNNPو، XAML nDدFD9ون א$ WPF h71zNNNP> . XAML אم$+ WPF h71 אوi\אSlWS5\و،\אoV h%א$.'نP]! HTML 03K3ًא7%$.N' :ً ^3אKPT Tags nD$F HTML אل$7!kN ﻛﻮد <a href="Ahmed.html">Ahmed</a> 'Sم$+F*א\وضN אن אYU Ahmed.html ROV אTQ Link aאHcQ'دאPא .Ahmed :ً ^3אKPT HTML 'אدאل9 AIC7Q¤NS 366 ﻛﻮد <img src="ahmed.jpg" alt="ahmed picture" border="0" /> . Qg Tagk@!(9'،ود$k@ وToolTip gQ$iH'bcQ'دPאאWS :אq NS53z$אNP> HTML 5D$Q\}!אG N' رابط http://www.html4arab.com/ ﻣﻼﺣﻈﺔ n+0.א\'אQ'1Uًא$%ًא$O3'نP+:FUYD 53^אWI]5+Qh3'3'نP − gD f אKMO\ א5F! 71 U 'Q`'אل 'دOو אC DreamWaverK^3 hאم אدوא$+ א03 .a7! وNotepad 030.א\'אhz$ ً V+, אWg!،Nbאh אدوאob'7Q1@אON، XAML _DUz$:ج3K'SאWS،g\א :ً ^33CHز ﻛﻮد <Button Height="80" Width="100"> ClickMe </Button> :I'عאNאאWSو ﻛﻮد <Button Height="80" Width="100" Content="ClickMe"/> :^ل3אWS،AICbNDnDIא$'d3CHزNQ$'نPQאن5P> ﻛﻮد <Button Height = "80" Width = "100"> <Button.Content> <ScrollBar Width = "75" Height = "40"/> </Button.Content> </Button> 367 ContentControl!JOא537T3 Scroll (אًنאل±I א\^لא5P ﻛﻮد <ScrollBar Height = "80" Width = "100"> <Button Width = "75" Height = "40"/> </ScrollBar > اﻟﺒﺪء ﻣﻦ ﺧﻼل ﻓﻴﺠﻮال ﺳﺘﻮدﻳﻮ .5 :אKPT WPF ApplicationHI .، New Project zTאHI.، Visual Studio !אنא :אzאnDZ.$Q$R، XAML אل,, ª9،*03و3CHز0s'. 368 Window VNאKIدאgsمووH'OאbND!P XAML 'دzT אKFم.،KOذF:א$` دFD9 אو אXAML 'دP3bאنא،FVאU!s9אbN א${ ً MQא،Grid . - GQو2343Nن−GQ'אh7103KOFFVאnD GSאذ، Title b}א.،مH'O'אنאND q Window *jVIUKQ$ولאنאRN אKPT ="WPF Example" GP53 وTitle HI'م753!و3 PC$א' وאQg :ً ^3 : אKPT XAML B9'دאP'نאP 369 ﻛﻮد <Window x:Class="WpfApplication2.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="300" Width="300" Title="WPF Example"> <Grid> <Button Height="23" Margin="99,0,105,91" Name="button1" VerticalAlignment="Bottom" Click="button1_Click">Button</Button> <TextBox Height="23" Margin="77,80,81,0" Name="textBox1" VerticalAlignment="Top" /> </Grid> </Window> .7Q1@אONhאدوאKP*jVא0BUPRאP3אنª9 g!Gא،FVt'د אP73iW!$` ،Y33אHزnDaqM3CX%אن :ً ^3א3א C# private void button1_Click(object sender, RoutedEventArgs e) { textBox1.Text = "Welcome WPF"; } ﻛﻮد VB Private Sub button1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) textBox1.Text = "Welcome WPF" End Sub ﻛﻮد :2Nوא 370 :אKPTFV א,,@OU'دPאNP>ًMQא ﻛﻮد <x:Code> <![CDATA[ void CodeExample(object sender, RoutedEventArgs e) { MessageBox.Show("ahmed"); } ]]> </x:Code> :ً ^3אKPT 3אH Click E$LאU:ZIאWא9אnDא$אאK%03 ﻛﻮد <Button Height="23" Margin="99,0,105,91" Name="button1" VerticalAlignment="Bottom" Click="CodeExample">Button</Button> ... VB.net لN(مN@אOو ...i,3$Q$%E$zT אVisual Studio لI53NP> Click E$RzNC ً MQC : - ﻧﻘﺎط ﺳﺮﻳﻌﺔ- ﺧﺎﺗﻤﺔ اﻟﺠﺰء اﻷول :NS53z$אNP>0' XAML X אصSyntax !אل35DRN' رابط http://msdn.microsoft.com/en-us/library/ms788723.aspx :ً ^3 אKPT Window لg!sאNP>:! I وForm_Load אلEא$CدFD9 ﻛﻮد Loaded="Window_Loaded" Closed="Window_Closed" 371 .hאدوאK*jVIوEא$C0B033@אOو لB$QN'5P،g(\ PRא53$Q\אON1]! WPF 037Q1אlWghHF 'אMicrosoft D'F 5Fs 53 Microsoft Expression Blend03 z$ אNPF! :! I وhg%א'א : ً ^3 jאg%'אiH'blWS،Expression ...3د.وسHدUgDfN وi,3 Visual Studio אلU:sوNP> XAML 'نPFFV2 372 WPF أدوات .6 K%C53gאHIوSg(353 q وC،i$Q$אhאدوא53D'F WPF !'،Q$7אh! دوאsא .k3א$+א :Q$7אhאدوאD'F:ً9وC *jV א0F a7! ، Q אدh אدوא. وLable, Button M t אi א\دhدوא9 אD'F . g(\ אYوKF`!sא :مH'OאhدوאC:ً .:! IوQFא,وאj'א7אK^3 : media אلhدوאC:ً^ .:! I'وQ$OوאiH'V وאh'VאhدوאCK^3 :g(\אhدوאC:ًאH . StackPanel وCanvas K^3i$Q$%AIC وPanel وאلGroupbox אلK^39אhدوא9אM :O+\ אWPF hدوאC53D'Fs'iH'Vא :אKPTg אصXAML و'دאل 373 ﻛﻮد <Window x:Class="WpfApplication3.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="240" Width="343"> <Grid> <Button Name="btnPurchaseOptions" Margin="10.5,51,10.5,41"> <StackPanel> <StackPanel Orientation = "Horizontal"></StackPanel> </StackPanel> </Button> <Expander Name="helpExpander" Header="Help" Height="23" HorizontalAlignment="Left" Margin="70,70,0,0" VerticalAlignment="Top" Width="51.757"></Expander> <Expander Name="fileExpander" Header="File" Height="23" HorizontalAlignment="Left" Margin="22,70,0,0" VerticalAlignment="Top" Width="44.95"></Expander> <Slider Height="21" Margin="21.757,0,19,75" Name="slider1" VerticalAlignment="Bottom"> <Slider.BitmapEffect> <DropShadowBitmapEffect /> </Slider.BitmapEffect> </Slider> <ProgressBar Height="15" Margin="23,0,19,50" Name="progressBar1" VerticalAlignment="Bottom" Value="50" /> </Grid> </Window> : WPF ﻧﻘﺎط ﺳﺮﻳﻌﺔ ﺣﻮل أدوات .:! Iوjوא$وאQوMلאP,א$Q$R Ellipse : QوMلאP,א:ً ^3 אKPTgN3KPOOI'نو$Q$نP39b אCombobox وאلC List bND- 374 :ً ^3אKPT*03CU Spell Check ]1אRVbIKO5P> ﻛﻮد <TextBox SpellCheck.IsEnabled="True" Height="23" Margin="20,44,16,0" Name="textBox1" VerticalAlignment="Top" Grid.Row="10" /> :אK^3'دQ5D'د%'\]א1+Kjא$!א35P>و C# string alterWords = ""; SpellingError error = textBox1.GetSpellingError(0); if (error != null) { foreach (string s in error.Suggestions) { alterWords += s + "\n"; } MessageBox.Show("Alternative Words:\n" + alterWords); } ﻛﻮد VB Dim alterWords As String = "" Dim [error] As SpellingError = textBox1.GetSpellingError(0) If [error] IsNot Nothing Then For Each s As String In [error].Suggestions alterWords += s + "" & Chr(10) & "" Next MessageBox.Show("Alternative Words:" & Chr(10) & "" + alterWords) End If ﻛﻮد 375 :אWSK^3ًJ,'نP2Nوא Data-Binding رﺑﻂ اﻟﺒﻴﺎﻧﺎت .7 !s'م7،i,3 TextBox ~ Slider .aً ^3،i,3 7Q1bND.aH01، WPF אلU :g1Hא\אدiدא אzאa7! ﻛﻮد DataContext = "{Binding ElementName=slider1}" Content = "{Binding Path=Value}" :אKPTK3P אXAML 'دVQ ﻛﻮد <Slider Height="27" Margin="20,40,16,0" Name="slider1" VerticalAlignment="Top" /> <Label Height="28" DataContext = "{Binding ElementName=slider1}" Content = "{Binding Path=Value}" Margin="20,72,16,0" Name="label1" VerticalAlignment="Top" BorderThickness="0"> 376 :2Nوא Wpf 2d .8 g,hN7nDfN ،i\אlWS WPF אلU5Pو$אjNh3'_ אAICi3'دN . WPF لI53i\אlWS5P وGDI+ Ug3N3tא :אhJO א53$وאnDאhאHI'Qא$ System.Windows.Shapes System.Windows.Media.Drawing System.Windows.Media.Visual Shapes اﻟﺮﺳﻢ ﺑﺎﺳﺘﺨﺪام .8.1 :ً ^3K13^ل3aC$، System.Windows.Shapes JOلאP,9א0B07 ﻛﻮد <Rectangle Height="100" Width="200" Stroke="Red" StrokeThickness="2" Fill="Aqua" /> 377 :אKPT'نP2Nא :ً ^3אKPT Object Browser Q5Dg'لb' אNP>gHNP>tلאP,א :^لFאKPTא،gN3KP,S$< אن5P>t*אjVאnDfאNNP>و 378 :ً ^3אiH'VאUi'د%'\ אshapes K 3*אjVאnDfאNP>F Pen ﺧﺼﺎﺋﺺ اﻟﻘﻠﻢ .8.2 :ً ^3אiH'VHFDאUم$+\א7 אoQQ ﻛﻮد <Pen Thickness="10" LineJoin="Round" EndLineCap="Triangle" StartLineCap="Round" /> . GDI+ UlNF}(9'ًא$%:, Brush ﺧﺼﺎﺋﺺ اﻟﻔﺮﺷﺎة .8.3 :gN3 ،71Ug3א$+א5P>شOא53א'عi$D¤NS .دD5Q':DrawingBrush .iH'b53z´KPTא53z%5Q' :ImageBrush .א'אنi$1IجH$ :LinearGradientBrush 379 .א'אنi$jج دאH$ :RadialGradientBrush .a7!$'نوאi,! :SolidColorBrush :a7!$ 'نوאSolid i,O אSgD^ل3aC ﻛﻮد <Ellipse Height ="50" Width ="50"> <Ellipse.Fill> <SolidColorBrush Color ="Aqua"/> </Ellipse.Fill> </Ellipse> :jא$جאH$ RadialGradientBrush אم$+^ل3 ﻛﻮد <Ellipse Width ="75" HorizontalAlignment="Left" Margin="28,30,0,96"> <Ellipse.Fill> <RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5" RadiusX="0.5" RadiusY="0.5"> <GradientStop Color="Yellow" Offset="0" /> <GradientStop Color="Red" Offset="0.25" /> <GradientStop Color="Blue" Offset="0.75" /> <GradientStop Color="LimeGreen" Offset="1" /> </RadialGradientBrush> </Ellipse.Fill> </Ellipse> :KP,KIدאiH'b53z%D1^ل3ً אICو ﻛﻮد <Rectangle Height ="100" Width ="300"> <Rectangle.Fill> <ImageBrush> <ImageBrush.ImageSource> <BitmapImage UriSource ="pic.JPG"/> </ImageBrush.ImageSource> </ImageBrush> </Rectangle.Fill> </Rectangle> :O+\شאOאh3א$+9!'وPQ30.'3532 380 : KbOא53$Q\aאאאWSو رابط http://msdn.microsoft.com/en-us/library/aa970904.aspx Transformations ال .8.4 NP>،م$+\אh I$}i]\אوאR\אbN אU*jVאlWSً^ א¤$O .!א\وhFא53:! IوgPD وSQو$لوP,אQ : مH'OאUNQ$i'د%'\אhאدوא53D'FnDhא] אs'Q א\^لא ﻛﻮد <Button Height="23" Margin="72,72,0,0" Name="button1" VerticalAlignment="Top" HorizontalAlignment="Left" Width="75">Button <Button.RenderTransform> <SkewTransform AngleX ="30" AngleY ="20"/> </Button.RenderTransform> </Button> <TextBox Margin="142,11,59,0" Name="textBox1" Height="23" 381 VerticalAlignment="Top">Ahmed <TextBox.RenderTransform> <TransformGroup> <SkewTransform AngleX ="20" AngleY ="20"/> <RotateTransform Angle ="45"/> <SkewTransform AngleX ="5" AngleY ="20"/> </TransformGroup> </TextBox.RenderTransform> </TextBox> :2NiH'blWSو :KP,אnDOH'V ] ًא$%KBWPF1aאאאWSnD رابط http://www.codeproject.com/KB/WPF/TransformationsIntro.aspx :1אiH'blWS 382 WPF ﻓﻲAnimation ال JO א Animation وאلQR אhF .9 7\وאل א$* وאjV ! א07 : *jVIE 53k$9Q$iאدאKV א، System.Windows.Media.Animation :DfN3'Sو،QRאg! QtאbوאQgNوאQא$ א17د$By : ،To ، From ...ً 79 :S lbNDSא، timeline ً MQא¤NSو ob'א VNא LאDUPR AccelerationRatio, DecelerationRatio Lאzgא$o+i'د AutoReverse c 0 F7 א، L אl$ C$ W א.'א BeginTime This 383 ,\אz$א LאFDg.qtאiZOא Duration z 'אL אzg א$ E$R ذא3 $Q$ FillBehavior, RepeatBehavior :! IوCiدD9א : Label Ua `אq،^ل3 C# DoubleAnimation dblAnim = new DoubleAnimation(); dblAnim.From = 10; dblAnim.To = 30; label1.BeginAnimation(Label.FontSizeProperty, dblAnim); ﻛﻮد VB Dim dblAnim As New DoubleAnimation() dblAnim.From = 10 dblAnim.[To] = 30 label1.BeginAnimation(Label.FontSizeProperty, dblAnim) ﻛﻮد :LאQא$ :LאQg :ً ^3 אKPTLאi$3$Q$5P> 384 C# dblAnim.Duration = new Duration(TimeSpan.FromSeconds(4)) ; ﻛﻮد VB dblAnim.Duration = new Duration(TimeSpan.FromSeconds(4)) ﻛﻮد :zg9א$L@אPو C# dblAnim.AutoReverse = true; ﻛﻮد VB dblAnim.AutoReverse = true ﻛﻮد :lzgא$אضiدDא$Q$NNP>و C# dblAnim.RepeatBehavior = RepeatBehavior.Forever; ﻛﻮد VB dblAnim.RepeatBehavior = RepeatBehavior.Forever ﻛﻮد :א\^لKnDa7!hא30H9:دDאوא C# dblAnim.RepeatBehavior = new RepeatBehavior(4); ﻛﻮد VB dblAnim.RepeatBehavior = new RepeatBehavior(4) ﻛﻮد 385 XAML اﻟﺤﺮﻛﺔ ﺑﺎﺳﺘﺨﺪام .10 5D אوXAML Q 5D3وא9 א53 א1 نP39 : א، وسH$ אlWS U ( אوR אWN3 N7O אF K%^ل 'ل3NQ$אن،@P'دوאPא53g'لb'א5P>*jVאlWS0B'د'نP אQ : Pro CSharp 2008X53−\وس:DaqMאU:Oאن'لHو$'م7QButton ﻛﻮد <Button Name="myAnimatedButton" Width="120" Height = "40" RenderTransformOrigin="0.5,0.5" Content = "OK"> <Button.RenderTransform> <RotateTransform Angle="0"/> </Button.RenderTransform> <!-- The animation is triggered when the button is clicked --> <Button.Triggers> <EventTrigger RoutedEvent="Button.Click"> <BeginStoryboard> <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="myAnimatedButton" Storyboard.TargetProperty= "(Button.RenderTransform).(RotateTransform.Angle)" Duration="0:0:2" FillBehavior="Stop"> <DoubleAnimationUsingKeyFrames.KeyFrames> <LinearDoubleKeyFrame Value="360" KeyTime="0:0:1" /> <DiscreteDoubleKeyFrame Value="180" KeyTime="0:0:1.5" /> </DoubleAnimationUsingKeyFrames.KeyFrames> </DoubleAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger> </Button.Triggers> </Button> styles ﺗﻌﺮﻳﻒ .11 D'FS وstyles fQ3NQ$אنfNGQ' א53ًא'ع7%$.Nذא ذ$ 5P> r ، darkstyle ً ^3 nF3 :! I'אن و9'ل وאض وא1د א$ *jV א53 .a7! style אאلPi אאدאUg3א$+א 386 ً ^33אH زKPob'א53`LאאWSKP'م75N אWPF אلUًMQC: ج3'SאWS :ً ^3אKPT style oQ'م7NאW، style @אلOk3CHאHאزi$DNQ$نCU ﻛﻮد <Window.Resources> <Style x:Key ="darkstyle"> <Setter Property ="Button.FontSize" Value ="15"/> <Setter Property ="Button.Background"> <Setter.Value> <LinearGradientBrush StartPoint="0,0" EndPoint="1,1"> <GradientStop Color="Black" Offset="0" /> <GradientStop Color="Blue" Offset="0.25" /> <GradientStop Color="Brown" Offset="1" /> </LinearGradientBrush> </Setter.Value> </Setter> </Style> </Window.Resources> :אKPToQאOPQ3CHزKPوאن ﻛﻮد <Button Name="b1" Width = "100" Style ="{StaticResource darkstyle}" Content = "Button 1" HorizontalAlignment="Right" Margin="0,61,30,61" /> <Button Name="b2" Width = "100" Style ="{StaticResource darkstyle}" Content = "Button 2" HorizontalAlignment="Left" Margin="25,61,0,61" /> :אKPT'نP2Nא 387 style ﺗﻐﻴﻴﺮ ﻃﺒﻴﻌﺔ ال.11.1 :!:'وa`א3אHز$Q$Rً ^3،م$+\ אstyle אلU'د%'\ אqVVz,אoQNP> :אKPT:OPQKK3P style אلqمQ 9o ﻛﻮد <Button Name="b2" Width = "100" Style ="{StaticResource darkstyle}" Content = "Button 2" HorizontalAlignment="Left" Margin="25,61,0,61" FontSize="30" /> :2Nوא ﻣﻦ آﺧﺮStyle اﺷﺘﻘﺎق .11.2 :אKPT:OQ5P> Q$. style 53lWICQ$Q$% style KF ﻛﻮد <Style x:Key ="darkredstyle" BasedOn = "{StaticResource darkstyle}"> Triggers ﺑﺎﺳﺘﺨﺪامstyle ﺗﺼﻤﻴﻢ .11.3 388 * 03 5Q' ً ^F! ، l א\وس אوHو3 E$r 13 i دאh9 $Q$ 53 Triggers אلNP> :אKPT styleGP$Q$RאnD:'V$NDo 'ن ﻛﻮد <Window.Resources> <Style x:Key ="txtstyle" TargetType = "{x:Type TextBox}"> <Setter Property = "Background" Value = "White"/> <Style.Triggers> <Trigger Property = "IsFocused" Value = "True"> <Setter Property = "Background" Value = "Yellow"/> </Trigger> </Style.Triggers> </Style> </Window.Resources> :$Q$Rא:DW*אNא0\2Nوא : ﺑﺮﻣﺠﻴ ًﺎ style $Q$53 وstyles אل53D'FgFj7 bND!sא، Pro CSharp 2008 53'ل7N3^ل3 :ً ^3אKPT S$CnD'R39אHز C# public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); ﻛﻮد 389 // Add items to our list box. lstStyles.Items.Add("TiltStyle"); lstStyles.Items.Add("GreenStyle"); lstStyles.Items.Add("MouseOverStyle"); } protected void comboStyles_Changed(object sender, RoutedEventArgs args) { // Get the selected style name from the list box. System.Windows.Style currStyle = (System.Windows.Style) FindResource(lstStyles.SelectedValue); // Set the style of the button type. this.btnMouseOverStyle.Style = currStyle; } } VB Public Partial Class MainWindow Inherits Window Public Sub New() InitializeComponent() ' Add items to our list box. lstStyles.Items.Add("TiltStyle") lstStyles.Items.Add("GreenStyle") lstStyles.Items.Add("MouseOverStyle") End Sub Protected Sub comboStyles_Changed(ByVal sender As Object, ByVal args As RoutedEventArgs) ' Get the selected style name from the list box. Dim currStyle As System.Windows.Style = DirectCast(FindResource(lstStyles.SelectedValue), System.Windows.Style) ' Set the style of the button type. Me.btnMouseOverStyle.Style = currStyle End Sub End Class ﻛﻮد :2Nوא 390 Templates ال .12 1 אK3P q אن01 g אstyles Y وgN قHO א5P و، h* אدوאjVI q ً MQم א$+ : TemplatesאلlWSً ^3،iدא 9א ﻛﻮد <Grid.Resources> <!-- A simple template for a round button for items in this grid --> <ControlTemplate x:Key ="roundButtonTemplate" TargetType ="{x:Type Button}"> <Grid> <Ellipse Name ="OuterRing" Width ="75" Height ="75" Fill ="DarkGreen"/> <Ellipse Name ="InnerRing" Width ="60" Height ="60" Fill ="MintCream"/> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> </Grid> </ControlTemplate> </Grid.Resources> :ً ^33CHS$Q$NP>وאن ﻛﻮد <Button Name ="myButton" Foreground ="Black" FontSize ="20" FontWeight ="Bold" Template ="{StaticResource roundButtonTemplate}" Click ="myButton_Click"> Click! </Button> 391 :2Nوא 3D WPF .13 אWS U ولRN ، د9 אjN ( g% و53 WPF _D U 'صq z$ : ج3 K NF אن$ . Avalon ~nFQ3אوWPF Uא_א^ אدh אnDfسאH$א !353 و9 ً وCאOא$NkאSO3ج، 2D_אلD5Dً ^ א3D_אلD o 3!}z$אNP> Graphics ل אلUNS*V+5Nو}א،:! I وProjection K^3SO\א :Qא3$7\אlWS لI53$Q رابط http://developer.nvidia.com/docs/IO/11278/Intro-to-Graphics.pdf ... WPF 03C$Nאن 3D _DUً3دو9אKPT א−مkאنא¤H$]! Graphics אلD03i4 אQ$' Oط7Y'ط1 א53D'F9'S3 Graphics - _אلDU Hello World :TQWא1وא אلhQ(gOجNPو−:% אو3−مk א:%وCد$DK^eh^^\א53D'Fg'لא7א01אو، iH'Vg(r 3DאلUh^^\אlWSN\ אh7دوא9א$Q$Rprojection ._אאWS03K3V+\אSوSystem.Windows.Media.Media3DJO'م אدא7NQא$ C# using System.Windows.Media.Media3D; ﻛﻮد 392 VB Imports System.Windows.Media.Media3D; ﻛﻮد אKPT،:! I אو3Pو'عאQ¯لא$Q$ 53NNP>W وאViewport3D oQً9جאوRN :ً ^3 ﻛﻮد <Viewport3D Name="mainViewport" ClipToBounds="True"> <Viewport3D.Camera> <PerspectiveCamera FarPlaneDistance="100" LookDirection="-11,-10,-9" UpDirection="0,1,0" NearPlaneDistance="1" Position="11,10,9" FieldOfView="70" /> </Viewport3D.Camera> <ModelVisual3D> <ModelVisual3D.Content> <DirectionalLight Color="White" Direction="-2,-3,-1" /> </ModelVisual3D.Content> </ModelVisual3D> </Viewport3D> :3אHزUو C# MeshGeometry3D triangleMesh = new MeshGeometry3D(); Point3D point0 = new Point3D(0, 0, 0); Point3D point1 = new Point3D(5, 0, 0); Point3D point2 = new Point3D(0, 0, 5); triangleMesh.Positions.Add(point0); triangleMesh.Positions.Add(point1); triangleMesh.Positions.Add(point2); triangleMesh.TriangleIndices.Add(0); triangleMesh.TriangleIndices.Add(2); triangleMesh.TriangleIndices.Add(1); Vector3D normal = new Vector3D(0, 1, 0); triangleMesh.Normals.Add(normal); ﻛﻮد 393 triangleMesh.Normals.Add(normal); triangleMesh.Normals.Add(normal); Material material = new DiffuseMaterial( new SolidColorBrush(Colors.DarkKhaki)); GeometryModel3D triangleModel = new GeometryModel3D( triangleMesh, material); ModelVisual3D model = new ModelVisual3D(); model.Content = triangleModel; this.mainViewport.Children.Add(model); VB Dim triangleMesh As New MeshGeometry3D() Dim point0 As New Point3D(0, 0, 0) Dim point1 As New Point3D(5, 0, 0) Dim point2 As New Point3D(0, 0, 5) triangleMesh.Positions.Add(point0) triangleMesh.Positions.Add(point1) triangleMesh.Positions.Add(point2) triangleMesh.TriangleIndices.Add(0) triangleMesh.TriangleIndices.Add(2) triangleMesh.TriangleIndices.Add(1) Dim normal As New Vector3D(0, 1, 0) triangleMesh.Normals.Add(normal) triangleMesh.Normals.Add(normal) triangleMesh.Normals.Add(normal) Dim material As Material = New DiffuseMaterial(New SolidColorBrush(Colors.DarkKhaki)) Dim triangleModel As New GeometryModel3D(triangleMesh, material) Dim model As New ModelVisual3D() model.Content = triangleModel Me.mainViewport.Children.Add(model) ﻛﻮد :'نP2Nوא 394 :GP\א3א C# private Model3DGroup CreateTriangleModel(Point3D p0, Point3D p1, Point3D p2) { MeshGeometry3D mesh = new MeshGeometry3D(); mesh.Positions.Add(p0); mesh.Positions.Add(p1); mesh.Positions.Add(p2); mesh.TriangleIndices.Add(0); mesh.TriangleIndices.Add(1); mesh.TriangleIndices.Add(2); Vector3D normal = CalculateNormal(p0, p1, p2); mesh.Normals.Add(normal); mesh.Normals.Add(normal); mesh.Normals.Add(normal); Material material = new DiffuseMaterial( new SolidColorBrush(Colors.DarkKhaki)); GeometryModel3D model = new GeometryModel3D( mesh, material); Model3DGroup group = new Model3DGroup(); group.Children.Add(model); return group; } private Vector3D CalculateNormal(Point3D p0, Point3D p1, Point3D p2) { Vector3D v0 = new Vector3D( p1.X - p0.X, p1.Y - p0.Y, p1.Z - p0.Z); Vector3D v1 = new Vector3D( p2.X - p1.X, p2.Y - p1.Y, p2.Z - p1.Z); return Vector3D.CrossProduct(v0, v1); ﻛﻮد 395 } ﻛﻮد VB Private Function CreateTriangleModel(ByVal p0 As Point3D, ByVal p1 As Point3D, ByVal p2 As Point3D) As Model3DGroup Dim mesh As New MeshGeometry3D() mesh.Positions.Add(p0) mesh.Positions.Add(p1) mesh.Positions.Add(p2) mesh.TriangleIndices.Add(0) mesh.TriangleIndices.Add(1) mesh.TriangleIndices.Add(2) Dim normal As Vector3D = CalculateNormal(p0, p1, p2) mesh.Normals.Add(normal) mesh.Normals.Add(normal) mesh.Normals.Add(normal) Dim material As Material = New DiffuseMaterial(New SolidColorBrush(Colors.DarkKhaki)) Dim model As New GeometryModel3D(mesh, material) Dim group As New Model3DGroup() group.Children.Add(model) Return group End Function Private Function CalculateNormal(ByVal p0 As Point3D, ByVal p1 As Point3D, ByVal p2 As Point3D) As Vector3D Dim v0 As New Vector3D(p1.X - p0.X, p1.Y - p0.Y, p1.Z - p0.Z) Dim v1 As New Vector3D(p2.X - p1.X, p2.Y - p1.Y, p2.Z - p1.Z) Return Vector3D.CrossProduct(v0, v1) End Function :3אHزUو C# Model3DGroup cube = new Model3DGroup(); Point3D p0 = new Point3D(0, 0, 0); Point3D p1 = new Point3D(5, 0, 0); Point3D p2 = new Point3D(5, 0, 5); Point3D p3 = new Point3D(0, 0, 5); Point3D p4 = new Point3D(0, 5, 0); Point3D p5 = new Point3D(5, 5, 0); Point3D p6 = new Point3D(5, 5, 5); Point3D p7 = new Point3D(0, 5, 5); //front side triangles cube.Children.Add(CreateTriangleModel(p3, p2, p6)); ﻛﻮد 396 cube.Children.Add(CreateTriangleModel(p3, p6, //right side triangles cube.Children.Add(CreateTriangleModel(p2, p1, cube.Children.Add(CreateTriangleModel(p2, p5, //back side triangles cube.Children.Add(CreateTriangleModel(p1, p0, cube.Children.Add(CreateTriangleModel(p1, p4, //left side triangles cube.Children.Add(CreateTriangleModel(p0, p3, cube.Children.Add(CreateTriangleModel(p0, p7, //top side triangles cube.Children.Add(CreateTriangleModel(p7, p6, cube.Children.Add(CreateTriangleModel(p7, p5, //bottom side triangles cube.Children.Add(CreateTriangleModel(p2, p3, cube.Children.Add(CreateTriangleModel(p2, p0, ModelVisual3D model = new ModelVisual3D(); model.Content = cube; this.mainViewport.Children.Add(model); p7)); p5)); p6)); p4)); p5)); p7)); p4)); p5)); p4)); p0)); p1)); VB Dim cube As New Model3DGroup() Dim p0 As New Point3D(0, 0, 0) Dim p1 As New Point3D(5, 0, 0) Dim p2 As New Point3D(5, 0, 5) Dim p3 As New Point3D(0, 0, 5) Dim p4 As New Point3D(0, 5, 0) Dim p5 As New Point3D(5, 5, 0) Dim p6 As New Point3D(5, 5, 5) Dim p7 As New Point3D(0, 5, 5) 'front side triangles cube.Children.Add(CreateTriangleModel(p3, cube.Children.Add(CreateTriangleModel(p3, 'right side triangles cube.Children.Add(CreateTriangleModel(p2, cube.Children.Add(CreateTriangleModel(p2, 'back side triangles cube.Children.Add(CreateTriangleModel(p1, cube.Children.Add(CreateTriangleModel(p1, 'left side triangles cube.Children.Add(CreateTriangleModel(p0, cube.Children.Add(CreateTriangleModel(p0, 'top side triangles cube.Children.Add(CreateTriangleModel(p7, cube.Children.Add(CreateTriangleModel(p7, ﻛﻮد p2, p6)) p6, p7)) p1, p5)) p5, p6)) p0, p4)) p4, p5)) p3, p7)) p7, p4)) p6, p5)) p5, p4)) 397 'bottom side triangles cube.Children.Add(CreateTriangleModel(p2, p3, p0)) cube.Children.Add(CreateTriangleModel(p2, p0, p1)) Dim model As New ModelVisual3D() model.Content = cube Me.mainViewport.Children.Add(model) :2Nوא :אaאאnDسH$אאWShQ'):N37אWאH$V\ א53h71אlWSUbא\'אNP> رابط http://www.kindohm.com/technical/wpf3dtutorial.htm :אKPT2N'نאP א3P אUPRא53NP>23KFDOnDא\ عNP>و 398 :אKPT'نPhsHCHאو XNA ﻋﺎﻟﻢ .14 % $. ]! ، _ א^ אد. D : z, C وC X א03 K3 א% $. N ذא אW،א_א^ אد03K3bאhP\ א53S وC OpenGL 03وC Direct3D 03K3א DirectX nDN3 API's אل53i$Q$%D'FS XNA نאلC.' ً boQ'نאPQ5 399 WON مg\وאل وא$ א53 د$Dg{ DirectX אلhP3 03 K3 אKg f$g .$gא53 ^PאWI]QSWONنtאhFא طZT gNP وS و، DirectX Next Generation Architecture : F` HVI אS XNA אل KFR.،'g XNA وعT3zT אP3'نPً79،KF'Q`'אل'دOא53 Express + :אaאא53XNA :aאאאWS53iدO9אNP>1ولN' رابط http://www.csharpcorner.com/UploadFile/mgold/XNAIntro04192007233237PM/XNAIntro.aspx :אKPT{2'نPو 4ول אR! W 5P _ ' 3C ... قHO אH אد01 ]! DirectX 2343 N אن ذא ...قHOאX% iZO DirectX אم$+ Microsoft Expression Studio .15 Microsoft Expression Web .15.1 400 K^3 i'د%'3 qb ] ROb KFD nD ¤$DQ وi 7Q1 ROb FV 234א אWS Q :אKPT:jאg%א'אXHTML, CSS, XML, XSLT ًMQ א¤NS ، *jV אnD KQ$ وאROb FV Q$ S${ t אhدوא9 א53 אم א$+ אNP> QKa7!אWS@،ً ^3 styles אل03K3אKg*jVI¤NS،z1I א. \אHTML .$3 . php لI53وC Asp.net لI53z'א: I534א234א :NS53z$אNP>$QF رابط http://www.microsoft.com/expression/features/default.aspx?key=web Microsoft Expression Design .15.2 אKPT:jאg%א'א،:! Iوh3'وאH'VאGKgiً9' 234אאWSم$7Q : 401 :NS53:!3NP>$Q\א رابط http://www.microsoft.com/expression/features/default.aspx?key=design Microsoft Expression Media .15.3 :g%'אiH'blWS،O+\א3 !C5Q'PوGوKQ$ 234אאWSQ 402 :NS53:!3NP>$Q\وא رابط http://www.microsoft.com/expression/features/default.aspx?key=media Microsoft Expression Encoder .15.4 53i$Q$אN7 אSilver Light iHدא9א234 אKPTQ،sوD03KDOjאvFאQ .ً Adobe 53ًو7 Micromeida 53 Flash N7 gT\و'!وאPQ3 :234 jאg%א'א 403 :NSKVOא53$Q}z$אNP> رابط http://www.microsoft.com/expression/features/default.aspx?key=encoder Expression Blend .15.5 KVO:ND$Q\!א3ولRN،FViد$3Kj'!وQ ،O+\אhg%وאFV ...سH$אאWSU :qT.،7אaאوא53ً9وC:FR. Expression Blend لI53a1KFDولאنRN :אKPT WPF Application (*.exe)53 وNew Project HIא53و 404 .015Q+نאP3! وs אframework وאلgD KFא$QtאqאHIאNP> وאضXAML ضD 535PF Split 0s'אZIא53 وActive Document View ZI אView 53 :אKPT.'@אOUאد 3אوאHאHزCوC،:! Iوi,Oوא7אz'אFVg جt אhאدوאK$`،,TאG%nD 405 bND I nD aqM אNP> ً MQ א، U g3$+ t אh אدوא53 :! I'ص وVN אh3و :ً ^3אKPThאدوא0BضFj7א g(\PRאgN301،GאnD*jVא53D'Fi אدא$`،אUFD لI ::! Iو bIiH'b:!0MNW אCanvas'אلSאWS،lאد$Q$R. وCanvas !s.،0Q1אن :h א] אgD1وN 406 ﻛﻮد <Canvas> <Canvas x:Name="MainImageCanvas" Canvas.Left="40" Canvas.Top="120"> XAML 2'نP، −i,3iH'b0s'.وC –ً ^3iH'b:!0MN وMediaElement !s.אن :אKPT ﻛﻮد <MediaElement x:Name="MainImage" Source="c:/example/futex.jpg" Width="300" Height="300" > </MediaElement> 'نP،*jV لאI53K\אFD1 Canvas אلnDh א] א1'م7Nوאن :אKPT XAML 2 ﻛﻮد <Canvas.RenderTransform> <TransformGroup> <SkewTransform x:Name="MainSkewTransform" AngleY="-19" AngleX="0" CenterX="0" CenterY="0"/> <ScaleTransform x:Name="MainScaleTransform" ScaleY="1" ScaleX = "1" CenterX="0" CenterY="0"/> </TransformGroup> </Canvas.RenderTransform> </Canvas> :אKPT'نPW ` אضوאF5 nDaqM.אن 407 0MNNSN{UوC،i,O*אjVI53i,3g71NP>، ًMQCiH'VK(אQ(1ولRN i\אlWSOK3Qزوא035PًوMQCiH'Vא:!0M وCanvas KF'م7NאW ،FgMnDYH'b :אKPT XAML 2'نP،iH'Vאfذאאr ﻛﻮد <Canvas x:Name="ReflectionImageCanvas" Canvas.Left="260" Canvas.Top="640"> <MediaElement x:Name="ReflImage" Source="c:/example/futex.jpg" Width="300" Height="300" Volume="0"> </MediaElement> <Canvas.RenderTransform> <TransformGroup> <SkewTransform x:Name="ReflectionSkewTransform" AngleY="19" AngleX="-41" CenterX="0" CenterY="0" /> <ScaleTransform x:Name="ReflectionScaleTransform" ScaleY="-1" ScaleX="1" CenterX="0" CenterY="0" /> </TransformGroup> </Canvas.RenderTransform> </Canvas> : אKPTiH'V2N'نאPو 408 XAML אل2$`אW،ًMQC*jVא5Fs53،K(אiH'V!OT! אsאSg3K3N17I :אKPT QgNאU ﻛﻮد <Canvas x:Name="ReflectionImageCanvas" Canvas.Left="260" Canvas.Top="640"> <MediaElement x:Name="ReflImage" Source="c:/example/futex.jpg" Width="300" Height="300" Volume="0"> </MediaElement> <Canvas.RenderTransform> <TransformGroup> <SkewTransform x:Name="ReflectionSkewTransform" AngleY="19" AngleX="-41" CenterX="0" CenterY="0" /> <ScaleTransform x:Name="ReflectionScaleTransform" ScaleY="-1" ScaleX="1" CenterX="0" CenterY="0" /> </TransformGroup> </Canvas.RenderTransform> <Canvas.OpacityMask> <LinearGradientBrush StartPoint="0.5,0.0" EndPoint="0.5,1.0"> <GradientStop Offset="0.345" Color="#00000000" x:Name="ReflGradientStop1" /> <GradientStop Offset="1.0" Color="#CC000000" x:Name="ReflGradientStop2" /> </LinearGradientBrush> 409 </Canvas.OpacityMask> </Canvas> ،b9אiH'VאnD71N3K(אiH'bK'دPא53 ًאوQو$Q Top وאلLeft אلhאدא$DאaM. :iH'Vא2 'نP : XAML K3P'دאPא ﻛﻮد <Canvas> <Canvas x:Name="MainImageCanvas" Canvas.Left="40" Canvas.Top="120"> <MediaElement x:Name="MainImage" Source="c:/example/FUTEX.JPG" Width="300" Height="300" > </MediaElement> <Canvas.RenderTransform> <TransformGroup> <SkewTransform x:Name="MainSkewTransform" AngleY="-19" AngleX="0" CenterX="0" CenterY="0"/> <ScaleTransform x:Name="MainScaleTransform" ScaleY="1" ScaleX = "1" CenterX="0" CenterY="0"/> </TransformGroup> 410 </Canvas.RenderTransform> </Canvas> <Canvas x:Name="ReflectionImageCanvas" Canvas.Left="267" Canvas.Top="645"> <MediaElement x:Name="ReflImage" Source="c:/example/futex.jpg" Width="300" Height="300" Volume="0"> </MediaElement> <Canvas.RenderTransform> <TransformGroup> <SkewTransform x:Name="ReflectionSkewTransform" AngleY="19" AngleX="-41" CenterX="0" CenterY="0" /> <ScaleTransform x:Name="ReflectionScaleTransform" ScaleY="-1" ScaleX="1" CenterX="0" CenterY="0" /> </TransformGroup> </Canvas.RenderTransform> <Canvas.OpacityMask> <LinearGradientBrush StartPoint="0.5,0.0" EndPoint="0.5,1.0"> <GradientStop Offset="0.345" Color="#00000000" x:Name="ReflGradientStop1" /> <GradientStop Offset="1.0" Color="#CC000000" x:Name="ReflGradientStop2" /> </LinearGradientBrush> </Canvas.OpacityMask> </Canvas> </Canvas> 1NQ ]@אOאن$`'وQ$!0s^ ًو3X% אW،z,'نאPאن5P> MediaElement @אنN9 ...ً 3e:D .iH'V@אONKF'وQ`'אل 'دO'אSF'دPאK7NP>ً Microsoft _D _א אWS 5D ^P ً }! א13 234F ] ¤ אن אذG א، QgN אK. .a7!{N אXAML אل03K3'אSFgQ 3K،YFFVFً bא:%'3'g!Expression :NS53z$אNP>D'F¡אlWS5D$Q3K رابط http://expression.microsoft.com/en-us/cc136522.aspx 411 اﻟﺒﺎب 17 ﻗﻮاﻋﺪ اﻟﺒﻴﺎﻧﺎت ADO.net 412 413 :ﻣﻘﺪﻣﺔ t אADO >$7א+N אد$3אS Active Data Object.net ًאHVIאf3 אوADO.net אل אوhאhودא3_ًMQאدא$3 אSو،!'وPQ353 6!`'אلhאHא$bאUi'د%'3 . DAO, RDO K^3 hN7 א53 $Q$ אh$g, وi$Q$D H'1 K }אh3 tאData Providers אدمY אو234وאhאi$D.YلVאOVVt אADO >$7א+N@ אPDnDو ًא1M3 V 5 r disconnected 3$x iود3 Rb אADO.net !¦نClient/Server KFوא .hאi$D7ًFjل دאV :S%'3אWSYN7אYAICh.!و¤NS . XML لK3PאD$א .3$+\وאل א$وאi$F\אh'אعאCiدQز .D אiدQز .K3P managed code Rbאgא :NSh.وO'لאKbOא53$Q3 nD ع9אNP> رابط http://msdn.microsoft.com/en-us/library/904fck4k(VS.71).aspx ADO.net اﻟﺒﺪء ﺑﺎﺳﺘﺨﺪام .1 'نP S$ ، System.Data ً אB S${، g b אhP\'א אد אS D 3 K a7! L אU ، Disconnected وC Connected 0s' ل אI 53 KF אU G N ذאF! Q7 D 'م7אوhאG` Kא3nDKV!^אLא3אhאi$D7jلدאVאnD'نPאو .Iא0s'ً79'دNF! Connected 03 A'K35ًNوHدQא$U،DFאh Q$א 414 ADO.net Data Provider ﻣﻜﻮﻧﺎت .2 .h אi$D7VאzTא53NP> :Connection−1 .hאi$D.nD SQL א مBWON53NPe:Command−2 א مFD 5D {N אh אizא. 53 NPe : DataReader DbDataReader IdataReader −3 .a7!$وאl{אUوa7!izא7'نP2Nא5P ،א\^لKnD h א53 iH'b nD 'لVL אnD NPe : DataAdapter DbDataAdapter IdataAdapter −4 .:! IوfWوKQ$! وsאKFDوgNK7Nא53NPeא موBولאو$%z''א1\א . م9אKBh אq3QFbI:Parameter DbParameter IdataParameter−5 اﻟﻤﺪﻋﻮﻣﺔ ﻣﻦ ﻗﺒﻞ ﻣﺎﻳﻜﺮوﺳﻮﻓﺖData Providers اﻟـ .2.1 :System.Data.OleDb U 'د%'3 I ود3 h אi$D7 ' ن5P ، h א$D'א. 53 א 'ع03 K3 g3א$+ א5P> .]1' אS'عNאאWS(אًن:3א$+אKMOQFj7א :System.Data.SqlClient مg\ א53 D'F nD ' g אSQL Server h א$D'א. 03 K3 g3א$+ً א3 دوKMOQ .hא$D'א.53'عNא אWS03K3bא :System.Data.SqlServerCe . Pocket PC אل03K3b אSQL Server CE hi$D.03K3אUg3א$+ אKMOQ :System.Data.Odbc .k I53:3K3א5P> Odbc o3א System.Data.OracleClient .k I53KאHوChא$D'א.03K3 אKMOQ 415 .2.2 Third-Party اﻟﺘﻌﺎﻣﻞ ﻣﻊ ﻣﺰودات ﺧﺪﻣﺔ أﺧﺮى ADO.NET Data Providers وC FoxPro وC MYSQL hא$D'א.5Dذא35Pو،jאhא$D'א7 hودא3ذ7אi7OאU ^ ً؟3DB2 ً؟iود$[אhP39]وא1אD אh ذאOleDb אم$+9QgNאU1MNKS م$7h, nوC ADO.netXbIg`N\Data Providers Q'1hTאGא3. ،ً 9 :gD^ل3aאאאWS،!s אh3$Iوhوא4אD0FbאhTא53i$F3hودא3 رابط http://www.sqlsummit.com/dataprov.htm System.Data ﻣﻜﻮﻧﺎت اﻟﻔﺌﺔ .3 z1IאKjHn*وjVIدوאلو53g3K3وאh א$D'א.*3KnDJOאlWS' :gVjVInDfאU$OJOאlWShQ')SCًQNS ضN،exceptions : IDbConnection Interface :وאلא$אnD'd،h אi$D7لV9bאJOقא7,אQ:N3 C# public interface IDbConnection : IDisposable { string ConnectionString { get; set; } int ConnectionTimeout { get; } string Database { get; } ConnectionState State { get; } IDbTransaction BeginTransaction(); IDbTransaction BeginTransaction(IsolationLevel il); void ChangeDatabase(string databaseName); void Close(); IDbCommand CreateCommand(); void Open(); } ﻛﻮد 416 VB Public Interface IDbConnection Inherits IDisposable Property ConnectionString() As String ReadOnly Property ConnectionTimeout() As Integer ReadOnly Property Database() As String ReadOnly Property State() As ConnectionState Function BeginTransaction() As IDbTransaction Function BeginTransaction(ByVal il As IsolationLevel) As IDbTransaction Sub ChangeDatabase(ByVal databaseName As String) Sub Close() Function CreateCommand() As IDbCommand Sub Open() End Interface ﻛﻮد : IDbCommand Interface :وאل א$אnD'd، م9אKBWON03ً79K3bאhJOقא7, א:N3Q C# public interface IDbCommand : IDisposable { string CommandText { get; set; } int CommandTimeout { get; set; } CommandType CommandType { get; set; } IDbConnection Connection { get; set; } IDataParameterCollection Parameters { get; } IDbTransaction Transaction { get; set; } UpdateRowSource UpdatedRowSource { get; set; } void Cancel(); IDbDataParameter CreateParameter(); int ExecuteNonQuery(); IDataReader ExecuteReader(); IDataReader ExecuteReader(CommandBehavior behavior); object ExecuteScalar(); void Prepare(); } ﻛﻮد VB Public Interface IDbCommand Inherits IDisposable ﻛﻮد 417 Property CommandText() As String Property CommandTimeout() As Integer Property CommandType() As CommandType Property Connection() As IDbConnection ReadOnly Property Parameters() As IDataParameterCollection Property Transaction() As IDbTransaction Property UpdatedRowSource() As UpdateRowSource Sub Cancel() Function CreateParameter() As IDbDataParameter Function ExecuteNonQuery() As Integer Function ExecuteReader() As IDataReader Function ExecuteReader(ByVal behavior As CommandBehavior) As IDataReader Function ExecuteScalar() As Object Sub Prepare() End Interface : IdbDataParameter :nD' C# public interface IDbDataParameter : IDataParameter { byte Precision { get; set; } byte Scale { get; set; } int Size { get; set; } } ﻛﻮد VB Public Interface IDbDataParameter Inherits IDataParameter Property Precision() As Byte Property Scale() As Byte Property Size() As Integer End Interface ﻛﻮد 418 : IdataParameter C# public interface IDataParameter{ DbType DbType { get; set; } ParameterDirection Direction { get; set; } bool IsNullable { get; } string ParameterName { get; set; } string SourceColumn { get; set; } DataRowVersion SourceVersion { get; set; } object Value { get; set; } } ﻛﻮد VB Public Interface IDataParameter Property DbType() As DbType Property Direction() As ParameterDirection ReadOnly Property IsNullable() As Boolean Property ParameterName() As String Property SourceColumn() As String Property SourceVersion() As DataRowVersion Property Value() As Object End Interface ﻛﻮد : IdbDataAdapter C# public interface IDbDataAdapter : IDataAdapter { IDbCommand DeleteCommand { get; set; } IDbCommand InsertCommand { get; set; } IDbCommand SelectCommand { get; set; } IDbCommand UpdateCommand { get; set; } } ﻛﻮد VB Public Interface IDbDataAdapter Inherits IDataAdapter Property DeleteCommand() As IDbCommand Property InsertCommand() As IDbCommand Property SelectCommand() As IDbCommand Property UpdateCommand() As IDbCommand End Interface ﻛﻮد 419 : IdataAdapter C# public interface IDataAdapter { MissingMappingAction MissingMappingAction { get; set; } MissingSchemaAction MissingSchemaAction { get; set; } ITableMappingCollection TableMappings { get; } int Fill(System.Data.DataSet dataSet); DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType); IDataParameter[] GetFillParameters(); int Update(DataSet dataSet); } ﻛﻮد ﻛﻮد VB Public Interface IDataAdapter Property MissingMappingAction() As MissingMappingAction Property MissingSchemaAction() As MissingSchemaAction ReadOnly Property TableMappings() As ITableMappingCollection Function Fill(ByVal dataSet As System.Data.DataSet) As Integer Function FillSchema(ByVal dataSet As DataSet, ByVal schemaType As SchemaType) As DataTable() Function GetFillParameters() As IDataParameter() Function Update(ByVal dataSet As DataSet) As Integer End Interface : IdataReader C# public interface IDataReader : IDisposable, IDataRecord { int Depth { get; } bool IsClosed { get; } int RecordsAffected { get; } void Close(); DataTable GetSchemaTable(); bool NextResult(); bool Read(); } ﻛﻮد 420 VB Public Interface IDataReader Inherits IDisposable Inherits IDataRecord ReadOnly Property Depth() As Integer ReadOnly Property IsClosed() As Boolean ReadOnly Property RecordsAffected() As Integer Sub Close() Function GetSchemaTable() As DataTable Function NextResult() As Boolean Function Read() As Boolean End Interface ﻛﻮد C# public interface IDataRecord { int FieldCount { get; } object this[ string name ] { get; } object this[ int i ] { get; } bool GetBoolean(int i); byte GetByte(int i); char GetChar(int i); DateTime GetDateTime(int i); Decimal GetDecimal(int i); float GetFloat(int i); short GetInt16(int i); int GetInt32(int i); long GetInt64(int i); //... bool IsDBNull(int i); } : IdataRecord ﻛﻮد VB Public Interface IDataRecord ReadOnly Property FieldCount() As Integer Default ReadOnly Property Item(ByVal name As String) As Object Get End Get End Property Default ReadOnly Property Item(ByVal i As Integer) As Object Get End Get ﻛﻮد 421 End Property Function GetBoolean(ByVal i As Integer) As Boolean Function GetByte(ByVal i As Integer) As Byte Function GetChar(ByVal i As Integer) As Char Function GetDateTime(ByVal i As Integer) As DateTime Function GetDecimal(ByVal i As Integer) As Decimal Function GetFloat(ByVal i As Integer) As Single Function GetInt16(ByVal i As Integer) As Short Function GetInt32(ByVal i As Integer) As Integer Function GetInt64(ByVal i As Integer) As Long '... Function IsDBNull(ByVal i As Integer) As Boolean End Interface SQL Server اﻟﺒﺪاﻳﺔ ﻣﻊ .4 . إﻧﺸﺎء ﻗﺎﻋﺪة اﻟﺒﻴﺎﻧﺎت .4.1 . אن1א.وz%و، ADO.net _DU9אhJOא53Ngא !`'אل+ KqT . אن، Employee YO&'F ً ^3 h i$D. zT א1 ول אنRN .3א زhوאH\אHI. 53و، Windows Forms i$Q$%'Q'د 03 i'د%'\א+NאK.9אnDאوE$وאC0אHא$b9א53 Sql Server +Q$'نPQ نC$9Qא$ :אaאאnD Express 'Q`'אل'دOא رابط http://msdn.microsoft.com/vstudio/express/sql .!'وPQ353¡אD'F¡א5Fs07tوא HIوא5>אHaqM .،GאnDl$` Server Explorer HI. View Fj.53אن :אKPTCreate New Sql Server Database 422 :אKPT Create aqsא9א$Q$Ra7!. ،hאi$D.zTאP3bאنא م$ 'نPQ PT\ אlWS K Gq אU ، : KV Kb9 אU ! 'د%م و$D PT3 g( $. *** .a7! . X%و−Z9لV'دא%مو$DUn−PTאKb'.a7!،PT Vא 423 : ]א1אHg(5Pא ! وg(Q$.*** An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) 53 وConfiguration Tools53 وMicrosoft SQL Server 2005 HI.23א4א53LאlWSU Surface Area *jV א5Fs 53 $` ، SQL Server 2005 Surface Area Configuration Local and *jVI אن53 $] وאgRO . ، Configuration for Services and connections .KFQ! نאC53$]ًMQא. ،O3remote connections : NS'لLא53D'F3 NP>ًMQא رابط http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=192622&SiteID=1 :אKPTYO&'\ אhول$%!sC$N،KFiS%وhi$D.Q$bאنא 424 אن،l وStored Procedurehאzא%9وאلوא$אK^3KPTא אWghQ')!אsאP3:אª9 :אKPTول$% !sאHINF. Identity KQ$ 'م7 autonumber : وset primary key HI 'م7 jH vO3 Y :אKPTאUF1iدQلא$3'S وIncrement $Q$R'م7 53 وyes Specfications 425 .7Q1@אON:!GK7 *אjVIو.KQ$NP>7Q1@אONو .i,3 אzאUh'אعאCnDfN .ً ^3 Employee_Info ول$אªOr.zg9א$ً אIא KPThلאIאدUz$gR!وQ$tאولא$ אאضאNP>،7אh'א1F.אن$ :א 426 :ً ^3אKPThلאIدF.،:! Iول و$אFViدDאNP>7Q1@אONو :SQL ServerUh'אعאC Exact numerics א¡ل 9,223,372,036,854,775,807 2,147,483,647 32,767 255 1 10^38 –1 53א¡ل 'عNא -9,223,372,036,854,775,808 -2,147,483,648 -32,768 0 0 -10^38 +1 bigint int smallint tinyint bit decimal 427 10^38 –1 +922,337,203,685,477.5807 +214,748.3647 1.79E + 308 3.40E + 38 -10^38 +1 -922,337,203,685,477.5808 -214,748.3648 -1.79E + 308 -3.40E + 38 Dec 31, 9999 Jan 1, 1753 Jun 6, 2079 Jan 1, 1900 numeric money smallmoney float real datetime (3.33 milliseconds accuracy) smalldatetime (1 minute accuracy) f8000nK7Q–`Lאf char f8000nK7Q–non-Unicodef varchar nKFnon-Unicodefو f231 varchar(max) f 2,147,483,647 nKFnon-Unicodefو text f 4,000 nKF Unicode fو nchar f 4,000 nKFUnicode fو nvarchar nKFnon-Unicodefو f 230 nvarchar(max) .f 1,073,741,823 nKFUnicode fو ntext .Q of 8,000 nKFjNh binary nKFi q3jNh of 8,000 Q. varbinary Q 231 nKFi q3jNh varbinary(max) .Q 2,147,483,647 nKFi q3jNh image (s'Q!'وPQ353ول$אאWg!، .netUh'אعאCF(مnDh'د$.Nوذא :.netUh'عK CLR.netUh'عא SQL SERVER SqlInt64 Int64, Nullable<Int64> Bigint SqlBytes, SqlBinary Byte[] Binary SqlBoolean Boolean, Nullable<Boolean> bit CLR h( 'عאSQL Server) 428 $%'Q9 $%'Q9 char $%'Q9 $%'Q9 cursor SqlDateTime DateTime, Nullable<DateTime> date SqlDateTime DateTime, Nullable<DateTime> datetime SqlDateTime DateTime, Nullable<DateTime> datetime2 $%'Q9 DateTimeOffset, Nullable<DateTimeOffset> DATETIMEOFFSET SqlDecimal Decimal, Nullable<Decimal> decimal SqlDouble Double, Nullable<Double> float $%'Q9 $%'Q9 image SqlInt32 Int32, Nullable<Int32> int SqlMoney Decimal, Nullable<Decimal> money SqlChars, SqlString String, Char[] nchar $%'Q9 $%'Q9 ntext SqlDecimal Decimal, Nullable<Decimal> numeric SqlChars, SqlString String, Char[] nvarchar SqlChars, SqlString Char, String, Char[], Nullable<char> nvarchar(1), nchar(1) SqlSingle Single, Nullable<Single> real $%'Q9 Byte[] rowversion SqlInt16 Int16, Nullable<Int16> smallint SqlMoney Decimal, Nullable<Decimal> smallmoney $%'Q9 Object sql_variant $%'Q9 $%'Q9 table $%'Q9 $%'Q9 text TimeSpan TimeSpan, Nullable<TimeSpan> time $%'Q9 $%'Q9 timestamp SqlByte Byte, Nullable<Byte> tinyint 429 SqlGuid Guid, Nullable<Guid> uniqueidentifier $%'Q9 iد$[אJO@אO User-defined type(UDT) SqlBytes, SqlBinary Byte[] varbinary SqlBytes, SqlBinary byte, Byte[], Nullable<byte> varbinary(1), binary(1) $%'Q9 $%'Q9 varchar SqlXml $%'Q9 xml SQL Statements .4.2 5Q'PوאzTאhF!sא:! IوKQ$!وאs9אhFDWONوhאi$D.Uh\א . Structured Query Language~HVIאSوSQLSqאlWS،hא$D'א.gFgOqج .S وAccess - MS sql Server− Oracle : hא$D'א.'אعC0B03KF م9אN7Vو אول$אzTوאKQ$وאfWL!وאs9אUًMQCم$+ gC9−0j,'SF−RFאlWS'م7 .و ذiHدא9وאgPR وא. hא$D'א.nو :lWSא مqUjوאلא$אSlWS 430 :SRg,א مאF3אqVא SQL Server Select Colums_Name From Table_Name; ﻛﻮد :zא%C HC53א مB'نPª .SQL KB 53S 5DRאBetאS و:Select .g(QنC:$QW'د אFوאCK7L אא:Colum_Name .RאF´bIqbًMQCS و:From .ول$א אGPNS :Table_Name :א مKF Syntex ( Q'RN א$D'א7)א:F5P>3nDz$אK.i(Nو .i qVوאi P אfאY!قC$%'Q9* .!3 53^]fZQ9:1CiTD=!ن3=!3* .ً4אh71Ugج9$.NC9'؛7N3bOא مKB0BgN* :7אFאnD^ل3אWSو SQL Server SELECT FName FROM Tb_Main; ﻛﻮد אجאאول+9ً ^F!،bOאgN KVO'אوgsوNNPF!'دFD53^Cאج+א$QNوذא : Iوאא SQL Server SELECT FName,LName FROM Tb_Main; ﻛﻮد : אKPT'لوذ7L אzאK)*0MN¦!hא0Bאج+9و SQL Server SELECT* FROM Tb_Main; ﻛﻮد 431 HאPאfW03אجאאول+9 ً ^F! DISTINCT ... م$+ HאP ون$ 5Pوhאجא+9و SQL Server SELECT DISTINCT FNAme FROM Tb_Main; ﻛﻮد :3مא$+ ً زNوCًQ$DV%+\אhאGZًMQC ORDER BY colum $DV وC ORDER BY colum DESC : אאولG $DVאGZא03 hא0Bאج+9ً ^F! SQL Server SELECT * FROM Tb_Main ORDER BY FName DESC; ﻛﻮد 53אאولوGGZً ^F!،bOאمא$+ وذ−0j,'SF−GZYQ'3KFDNNP>و : Iאא SQL Server SELECT * FROM Tb_Main ORDER BY FName,Lname ; ﻛﻮد :אqVא م אFDUطTiאمא\وא$+אqbWI] SQL Server Select * From Tb_Main Where Field = Value; ﻛﻮد . = ً و >< وC =< وC => وC < وC > אم$+אNNP>و . Between وLike FS ً و79¦ذنאgTNد$%Y33ً אICو : N 18SHFDCو5QWאz.$bא5D^ ً مF! 432 SQL Server SELECT * FROM tb_Main WHERE age = 18; ﻛﻮد :N5053qbCS53zCوض SQL Server SELECT FName,LName FROM tb_Main where age < 50; ﻛﻮد ص+, א5DR−אKPTًوذb'VUiدO3*VNt3 DY Value 0MNو :( $"C)אk5QWوא SQL Server SELECT * FROM tb_Main WHERE Fname = 'ahmed'; ﻛﻮد g,qbWI]gNP،hאi$D.U¢QH^3C $%'9و،¢QH'א5DRא$ND#t3 D0MNF : SQL Server Select * Form Table1 Where Date > #12/03/04#; ﻛﻮد ؟IzOא03ط,7وCS$CوCوط,D'F7R RدאHC'ذא3:وאن .4אhqUNFFOrوAnd1א71N\אh 3\مא$+ضqאאWSK%C53 : Y%و3''אPQ9CطT175DSFD 4PQ5QWصא+,א5DRN،0Q^ل3وאن SQL Server Select Fname from tb_main where age > 17 and marry = false; ﻛﻮد : Like K3\אمא$+א ... Y3 gT\אhFPא5DR Like K3\مא$+ : אqV אLike K3Fم$+و 433 SQL Server ﻛﻮد Select * From Table Where Field Like '%Name٪'; U3אMو.FgوC،QgNوאC،Qא$אU g3$+$.و...3fC'د%وnD9$٪م$+ :^3א :KPTאאWgא مBم$+N ... hm nDאوSzC'$.5QWصא+,ض א SQL Server SELECT * FROM Tb_Main WHERE FName like '%hm%'; ﻛﻮد : RאFK.٪0M5אW A fr SzCC$5QWصא+,א5DRدאHC'3C SQL Server SELECT * FROM Tb_Main WHERE FName like 'A%'; ﻛﻮد .QgNدونאQא$אU٪0MNY3 frgאgNQ5QWصא+,א5DRدאHC'و ﻣﻼﺣﻈﺔ % نستخدم * بدال ً منMS Access في ؟fوLدא$D$Q$دHC'ذא35P ،fوLא53د$DCc٪نC2N .""؟SOא3 D'SAccessUS&N3،"_"م$+'LאlWSU 3א % _ (underscore) [] אم$+א ًא$DV!Ob53zא$אfא53د$DC .a7!$وאf NوאلAאلYfً ^3،Y3A$353a7!$وאf Like '[A-N]ack' [^] Like '[^B]ack' 'نPQ9fً ^3،د$['אS'نPQ9C1Q,a7!$وאf B 434 .a7! 3g!دو$D'نPQنCطT A frSzC C$5QWصא+,א5DRنCدHC'ذא3:ذن SQL Server SELECT * FROM Tb_Main WHERE FName like 'A__'; ﻛﻮد . Between اﺳﺘﺨﺪام اﻟﻤﻌﺎﻣﻞ 5FsRאU:3א$+'אSK3\אאWkلF אg,Cو،Y3ق15FsRK3\אאWSم$+ .¢QHא'א :אqV אbetween אم$+RאWI]Q SQL Server SELECT colum FROM table WHERE field BETWEEN v1 AND v2; ﻛﻮد :60 و20 YSHFDCvوאZ5QWصא+,אجא+9ً ^F! SQL Server SELECT * FROM tb_main WHERE age between 20 and 60; ﻛﻮد .لLא1 ¢QHوא'א،zא037Q1@אOאم$+א5P>و .اﻟﺪوال ﻓﻲ اﻻﺳﺘﻌﻼﻣﺎت −i$وF.$و،d3و،אم$+9אj,Sو، م9 אKBh5Fsوאل$א53$Q$مא$+ .سH$אאWS لI^3א03وאل$אnDfN - ول$%$9 : אKPTאWI]tوאلوא$אمא$+93אqVאQi((NNو SQL Server SELECT func(colum) FROM table WHERE condition; ﻛﻮد : AVG א$א 435 :ًא3CGPً ^3hאi$D.UHFD אa'3XLو،3K7a'3א$אlWSN1 SQL Server Select AVG(Age) from tb_main; ﻛﻮد Kم.Hא0F<h `א0BnDHو$NN،א$אlWSم$+_ 'KONذא3K+وאن - .ً −אWPS אوK7NK` :255DSHFDC$Q95QWصא+,אHFDCa'3XL ً ^F!...طTא$אمא$+אNNP>ًMQC SQL Server SELECT AVG(Age) FROM tb_main where age < 25; ﻛﻮد −$QNذא−.אW...:, 3وC Expr100 אK7Ug(Qא$א2نCh$%' (9' :אKPTًو7NFF As Q5D2NאK7FiدD SQL Server SELECT AVG(Age) as AVGAGE FROM tb_main WHERE age < 25; ﻛﻮد ﻣﻼﺣﻈﺔ ..الحظ أن الدالة سوف تتجاھل السجالت الفارغة : Sum,Max,Min اﻟﺪوال :hאi$D.UFD4CnD^ل3אWSو، א'אnDqbא−4א−'عF¡وאلא$אlWS1 SQL Server SELECT max(Age) AS mxAGE FROM tb_main; ﻛﻮد ﻣﻼﺣﻈﺔ .ال تنس أن بإمكاننا وضع شرط لعملية اإلستعالم 436 : Count اﻟﺪاﻟﺔ :h `دא$Dً ^3$N،h `دא$Dא$אlWS$و SQL Server ﻛﻮد SELECT COUNT(*) FROM Table1; :hאHאPאKS`و SQL Server SELECT COUNT(DISTINCT Title) FROM Table1; ﻛﻮد : اﻟﻌﻼﻗﺎت KFאUGوh. D NQ$ 'ذא3، وאنTSql Uig,^9وא1وאلא$אlWS :אKPTFمא$+f'LאlWSU .gD ﻛﻮد SQL Server SELECT tb_main.Fname, tb_main.lname, Tb_R1.passport, tb_r1.bclass, tb_r1.from FROM tb_main, tb_r1 WHERE tb_main.Number = tb_r1.Number; :7 א7Q1وא7Q1אlWSYوقOאª אنNDد .ول$%53^C03K3N g3وذK7Lאא.ول$אאP'م7:ً9وC .ول$%53^C532'אNא$Q N FromiHD$ول$%53 ^אP'م7:ً .Q'Yو$אUg3.HC:Ttאh3'\ضאQP'S م9אB 53 Iא1א:ً^ : DDL :אKPTول وذ$% zT אqVً9وCC$N،hא$D'א.KS03K3*§DDLنCذ SQL Server CREATE TABLE tb1 ( colum type, colum type,........); ﻛﻮد 437 − *)'ع53 Name א،Y7nD'd Tb2 ًא9و$%±TNN...ذnD^لFو : Number 'ع53 Age I( وאString SQL Server CREATE TABLE tb1 (name text,age number ); ﻛﻮد Y'.Yhدא$D0sذن...a7!hI@Fx Name FאK7`د$نCدHC'ذא3ذن :אKPT وذText ¤9אh'عY 03 SQL Server CREATE TABLE tb1 (name text(6),age number ); ﻛﻮد 03אא\^لWSX`Nو... - Null !אغK7Q9K7LאK< oSאول$אzTאUg,]17I :ً MQCא SQL Server CREATE TABLE tb1 (name text(6) Not Null,age number ); ﻛﻮد :' ًאlzT¦NF.Wولא$אfWr 'م7Q'دPאאWS0.א'אU ... fWL א5Dذא35Pو SQL Server DROP Table tb1; ﻛﻮد אKPT'دوذPאI CASCADE !sg^Q$53 $ !h. ً13ول$אאWSو'ن SQL Server DROP Table tb1 CASCADE; ﻛﻮد hאi$D.ولو$אY قOنאC$7DC−zT9אFD$وذ: 'ل7 !s אUC$Nوאن - .ًRsوאbC'ل7Lوא :א7Q13DqV'ل7L!אsא01 SQL Server ALTER TABLE tb1 ADD colum type; ﻛﻮد 438 :( n^C−'ع)ذN א\ دوא^א¢QH'Sאول:5Q$Q$%Y7oMN! SQL Server ALTER TABLE tb1 ADD birth_Date date,Gender Text; ﻛﻮد Q$R CASCADE FoMًFjدאNCª9 Gender ... K75P'ل و7L אlWS$CfWRN وאن :אKPTوذ،−S'د%لوU - h. א SQL Server ALTER TABLE tb1 DROP gender CASCADE; ﻛﻮد .AICi3DML Tb_Main م$+f'و، h `!אs אنאf'DMLU م9وאRאz%NFאن$ :!sא3 3אqVوאنא،:D3وאCX`Nول$` SQL Server INSERT INTO table VALUES (v1, v2,......); ﻛﻮد ""*VNt3 DY'صVNא0sوiDא303،b!gNKVOא^ وzאHאًو$وא7אHFNNCª9 . ## t3 D Y¢QHوא'א −وZPא$Q4א−'אنNא−Fא−okא.H− I אא- אאول−.א:א7אHFN :אKPTوذ، h( 3−9/وج3−0.'\ א- qא−Nא ﻛﻮد SQL Server Insert into tb_main values(11,'ahmed','gamal',6666666,18,'Cairo','Hammada2091','First Year','','',false,''); :KQ$א :אKPTK`hKQ$3אqVא 439 SQL Server UPDATE table_name SET colum1 = v1 , colum2 = v2 WHERE colum = v; ﻛﻮد ( Ahmed אول:אW*א+T = www.vb4arab.com 0.'\وא25=FאKً9^3אنX`N : ( Gamal ) I9)وא ﻛﻮد SQL Server Update tb_main set age=25 , site='www.vb4arab.com' where fname='ahmed' and lname='Gamal'; :3DqbRאB W+0.א'אU ... fWL א5Dذא35Pو SQL Server DELETE FROM table WHERE colum = value; ﻛﻮد ص+,א0BfWf'א\^لאU..ط, 53^C7 ]fWL'نאPQنC5P>و :YHא5DSHFDC$Q5QWא SQL Server Delete from tb_main where age>40; ﻛﻮد :7Q1אSlWS ... 3ول$%hQ')K3 fW 5Dذא35Pو SQL Server DELETE * FROM table; ﻛﻮد Stored Procedure .4.3 ضN אW و، ًא$% a 'عs'\ א، h אi$D. U א مB 'S Stored Procedure אل :א مBQ' SQL Server select [First Name] from employee_info where age>21; ﻛﻮد 440 :אKPT Procedure ل:Q'Q3'Sو SQL Server Create PROCEDURE dbo.GetAge @firstname char(10) output AS SELECT @firstname =[First Name] from Employee_info where age > 21 ﻛﻮد .Stored ProcedureאאلAlterوCCreateאول1א− .OutputوCInput:7Qو:D'$Q$Qreturn valueوאلChאZ3HאnD'd^א1א− .א مB^א1א− : م9אlWS :!GPو$Q$%$وאzTאH+N وStored Procedure .GSWNوאن אWSK^3ًJ,2N'نאP و، Excute HIאQ5D2N{אNP> 441 :^لFאKPTא،X'1\طאT^ ًא3$Q$RZ3HK7 م9אBK%NP> SQL Server ALTER PROCEDURE dbo.GetAge @condition int, @firstname char(10) output AS SELECT @firstname =[First Name] from Employee_info where age > @condition ﻛﻮد م9אBWON'م7 SQL ServerאلUnאو234א53z'אZ3HQeNP>LאlWSU .:אnD Gو، Select 53ً9$ Insert وC Delete אوUpdate م9אB@OKFDP3نC@N9ً .'1\ مא9אB SQL Injection .4.4 W אz'אSאWg!i,3 م9אKB53ً9$ Stored Procedure م$+!\ذא3$Q N' .ً^ א:gنCD 442 :Hא\وFمو$+\אאQ5D،'لI$אK`F'م7KIدאCضZON ﻛﻮد SQL Server string cmd = "select id from Users where nams like '"+textBox1.Text+"' and pass like '"+textBox2.Text+"'"; ضZONوאن،`N'د5!@PאU3CIDF.א$א$f'!'د%'3'نא:C1א :*אولNא03UאzאPم.3ًV+,نC —('insert into Users values(1,'NewUser','1234 'لI$א:P3'نP7 אi\אU، ول$`م$+\אאWS!s'م7:NPو،i\אlWSKI$Q5 !!!1234.وNewUser :طTא7RאWg!،*Nא3UאFאPم.'،ذ53aوאC a' or 't'='t 'ع؟s'\אאWS:QنC5P>WאHM§`אKS :P'م7QنCًMQC5P> –drop table Tablename !!!a7!و gNP> 9 وa7! q3 33 K3 q\ אKI دאkI אدQ F. C نC U Stored Procedure ~ א¤$O ...ً79gDfNAIC7Q1gFDNNP>و،ًא$CWONא 443 اﻟﻌﻼﻗﺎت .4.5 :אWSK^3 ً J,2N'نאP،o&'3KgDKFQtא0QHT\א:!0Mً ^3D!ول$% KF. 7אGR. وAdd New HI.، Database Diagram $`אFj7א53،h. אa :ً ^3אKPT . אUg1H'دtא SQL _D U $Q\ אnD f אG N ' Sql Server U ^ ًא: جNg א$. 'نP NS :NS53z$אNP>Server رابط http://msdn.microsoft.com/en-us/sqlserver/default.aspx ...4אqAICi3'دNوאن 444 اﻟﻮﺿﻊ اﻟﻤﺘﺼﻞ .5 ConnectionStringBuilder اﻟﺘﻌﺎﻣﻞ ﻣﻊ .5.1 ^ אs'Q א א\^لWS ، אصConnectioString אلzN VO 7Q 5jPא אWS !'Q :ً 3א$+א C# SqlConnectionStringBuilder cnStrBuilder = new SqlConnectionStringBuilder(); cnStrBuilder.InitialCatalog = "Employee"; cnStrBuilder.DataSource = @"(local)\SQLEXPRESS"; cnStrBuilder.ConnectTimeout = 30; cnStrBuilder.Password = "124"; cnStrBuilder.UserID = "Ahmed"; SqlConnection cn = new SqlConnection(); cn.ConnectionString = cnStrBuilder.ConnectionString; cn.Open(); ﻛﻮد VB Dim cnStrBuilder As New SqlConnectionStringBuilder() cnStrBuilder.InitialCatalog = "Employee" cnStrBuilder.DataSource = "(local)\SQLEXPRESS" cnStrBuilder.ConnectTimeout = 30 cnStrBuilder.Password = "124" cnStrBuilder.UserID = "Ahmed" Dim cn As New SqlConnection() cn.ConnectionString = cnStrBuilder.ConnectionString cn.Open() ﻛﻮد :${ hאi$D.א$Q$R- InitialCatalog hאi$D. H3$Q$R- DataSource אوh אi$D. 'لb' )و אK% א53 :.אq א5P> W א.' א$Q$R - ConnectTimeout .lzgא$NDFאf7Qא .h$%نوhאi$D.Hو3F- Password .$%ن وhאi$D7م$+\אא- UserID 445 :NS53gs אאNP>ًMQCAIאbNא53$Q$א¤NS رابط http://msdn.microsoft.com/enus/library/system.data.sqlclient.sqlconnectionstringbuilder_members.aspx Command اﻟﺘﻌﺎﻣﻞ ﻣﻊ اﻟﻔﺌﺔ .5.2 7N،hאi$D.nDhFא53א'عWON g3$+t مא9אBS Command אل :jHא'אعE StoredProcedure− TableDirect− Text− :ً ^3אKPT،Texti,3V א مF` Command אلN3$+א\^لאאU C# string strSQL = "Select * From Employee_Info"; SqlCommand myCommand = new SqlCommand(strSQL, cn); ﻛﻮد VB Dim strSQL As String = "Select * From Employee_Info" Dim myCommand As New SqlCommand(strSQL, cn) ﻛﻮد :KPTאאWgوC C# SqlCommand testCommand = new SqlCommand(); testCommand.Connection = cn; testCommand.CommandText = strSQL; ﻛﻮد VB Dim testCommand As New SqlCommand() testCommand.Connection = cn testCommand.CommandText = strSQL ﻛﻮد 446 :WON قi$Dقi$D¤NS0.א'אU، ExecuteReader אم$+i,3g1NF.WON אzNC : 2N אaH وDataReaderoQ Q ، h א53 د$D 2N 'ن אU : ExecuteReader .7Kא3U:D N!3'Sو،:zא7 2N אDelete אوupdateFDoQ K^3،ً bא2'د'א%مو$DU: ExecuteNonQuery .ً 79:Df א،:3$D53FאWON'S$'א .אGb*+Tאول9א5Da7!5D م9אK^3،$و2N'نאU: ExecuteScalar . xxxxxx 3'7א ،:zא7:2NאaH وXmlReaderoQQ XML KP,nD:دDوא2NאWON:ExecuteXmlReade . XmlReader 5D$Q\ \!אXML وسH'عد%אNP> : Parameterized Command Objects اﺳﺘﺨﺪام الK( م9אKFQ$7א7Q1!¦نא، SQL Injection אل5D:!N$WسאH$ א53(9F Stored 03 K3 5P _ ' n ً MQ אNQ$ م9 אKF Parameters אم$+ C$ אW ، i1I .Procedure :` א\^لאWIC' ﻛﻮد C# string strSQL = "Select [First Name]+[Last Name] as [Full Name], Age From Employee where ID=" + ID; SqlCommand myCommand = new SqlCommand(strSQL, cn); ﻛﻮد VB Dim strSQL As String = "Select [First Name]+[Last Name] as [Full Name], Age From Employee where ID=" + ID Dim myCommand As New SqlCommand(strSQL, cn) אم$+ 'نPQ KQ$א אW ، 'g (مNא אWS אقZI א53 SQL Injection }د¨ אل5QHد. N א$` : SqlParameteroQو ﻛﻮد C# string sql = string.Format("Select [First Name]+[Last Name] as [Full Name], Age From Employee where ID=@ID"); 447 using(SqlCommand cmd = new SqlCommand(sql, this.sqlCn)) { // Fill params collection. SqlParameter param = new SqlParameter(); param.ParameterName = "@ID"; param.Value = 10; param.SqlDbType = SqlDbType.Int; cmd.Parameters.Add(param); // NSKP,] م9אBWON cmd.ExecuteNonQuery(); } ﻛﻮد VB Dim sql As String = String.Format("Select [First Name]+[Last Name] as [Full Name], Age From Employee where ID=@ID") Using cmd As New SqlCommand(sql, Me.sqlCn) ' Fill params collection. Dim param As New SqlParameter() param.ParameterName = "@ID" param.Value = 10 param.SqlDbType = SqlDbType.Int cmd.Parameters.Add(param) ' NSKP,] م9אBWON cmd.ExecuteNonQuery() End Using .234א5FsgP5NF.א مB hאZ3HQFNF.(9FNS Bً ^3NsZ! 'א، Stored Procedure oQSאم$+9אjTאSوNQ$tא^אL א :אKPTNسHولدCUS]TCt مא9א SQL Server ALTER PROCEDURE dbo.GetAge @condition int, @firstname char(10) output AS SELECT @firstname=[First Name] from Employee_info where age > @condition ﻛﻮد 448 :ً ^3אKPT ذQ،234א53SzD$א$Qאن، GetAge g(OrNF.و C# using (SqlCommand cmd = new SqlCommand("GetAge", cn)) { cmd.CommandType = CommandType.StoredProcedure; SqlParameter param = new SqlParameter(); param.ParameterName = "@condition"; param.SqlDbType = SqlDbType.Int; param.Value = myAge; param.Direction = ParameterDirection.Input; cmd.Parameters.Add(param); ﻛﻮد param = new SqlParameter(); param.ParameterName = "@firstname"; param.SqlDbType = SqlDbType.Char; param.Size = 10; param.Direction = ParameterDirection.Output; cmd.Parameters.Add(param); cmd.ExecuteNonQuery(); MessageBox.Show(cmd.Parameters["@firstName"].Value.ToString()); } VB Using cmd As New SqlCommand("GetAge", cn) cmd.CommandType = CommandType.StoredProcedure Dim param As New SqlParameter() param.ParameterName = "@condition" param.SqlDbType = SqlDbType.Int param.Value = myAge param.Direction = ParameterDirection.Input cmd.Parameters.Add(param) param = New SqlParameter() param.ParameterName = "@firstname" param.SqlDbType = SqlDbType.[Char] param.Size = 10 param.Direction = ParameterDirection.Output cmd.Parameters.Add(param) cmd.ExecuteNonQuery() MessageBox.Show(cmd.Parameters("@firstName").Value.ToString()) End Using ﻛﻮد 449 q3oQNF.53و، Text 'SsאZ!9(אًنאNS Command 'عאلoQNF.،(9F .ً MQC אوجq3'لوI$א DataReaders اﻟﺘﻌﺎﻣﻞ ﻣﻊ .5.3 :אKPTאمא$+א5P>،א3 DataReader 53hאizא.دHC' ﻛﻮد C# string listItem = ""; while (myDataReader.Read()) { listItem= "Full Name: " + myDataReader["Full Name"].ToString() + " Age: " + myDataReader["Age"].ToString(); listBox1.Items.Add(listItem); } VB Dim listItem As String = "" While myDataReader.Read() listItem = "Full Name: " + myDataReader("Full Name").ToString() + " Age: " + myDataReader("Age").ToString() listBox1.Items.Add(listItem) End While ﻛﻮد K7NkzD$אK03.'@אOUو،izא7h `¤NS دאم3 true X Read א$'دא ...אK`א GZ אU :F.H $Q$R אوmyDataReader["Age"] :zא. א\אدK7L א$Q$R 'نP izא7 א7Q .ً ^3myDataReader[2] 2jNא5Fsi$FDدא$DN1t وאFieldCount bًאMQC¤NS 450 : NextResult z אYO&'\ אz אiدD9 ً ^F! ، 2N אiدD9 א مtB oQ 53 DataReader אلNPe :0QHT\א C# string strSQL = "Select * From Employee_info;Select * from projects"; SqlCommand myCommand = new SqlCommand(strSQL, cn); do { while (myDataReader.Read()) { for (int i = 0; i < myDataReader.FieldCount; i++) listItem= "Data: " + myDataReader[0].ToString() ; } } while (myDataReader.NextResult()); ﻛﻮد VB Dim strSQL As String = "Select * From Employee_info;Select * from projects" Dim myCommand As New SqlCommand(strSQL, cn) Do While myDataReader.Read() For i As Integer = 0 To myDataReader.FieldCount - 1 listItem = "Data: " + myDataReader(0).ToString() Next End While Loop While myDataReader.NextResult() Data Access Layer ﻛﻮد .6 QK،hא71!sא234אhFD'وQHN03g(\ א03'دPא0sوQ9،Q$אh71אU %א3NP>'عs'\אאWS5D$Q\\!א، Layers fQ3'SوVON37 UgN3KKV! :אaאא رابط http://www.al-asiri.com/ShowRecord.aspx?Action=Open&id=cefa426c-d9e0-4625a66b-87fd6082ff89 451 :NSًMQא1¤NSو رابط http://vb4arab.com/vb/showthread.php?t=10969 :YFg3Y177Rhא$D'א.03K3bI 'نP data layer KFDولRN،\אlWSU .i353^אg3א$+אiدDא .71אlWSnDA'KQ$אQ9KQ$אUو،'g lH$V3$Q$Q]1I'د%وU:Q$3Kאن،hאi$D7لV9אO 234א53z%א2343ق1Q5LאlWSUو دونN3 hאZ3H 03 S$QQ t אhF אK وKQ$ وאfWLل وאV وאل$ א53 D'F S .ً 3ehא$D'א7لV9אOU KI$א KF'م7 وFאlWg'م7tאiSא23א4אمא$+אg1א،قi$71אlWS KFDNP> ، F אlWk 7Q hو$'! אQ ً MQ א، Sد$ t א4 אq G layer אلlWk אج+א ...Qو$א7Q1אS^א7Q1א nDSO\@אO15P>،YO&'\אK%א53F אlWka^ل3nDfNא`אU .79Q$א23א4א : ﻋﻤﻠﻴﺎت ﻓﺘﺢ واﻏﻼق ﻗﻮاﻋﺪ اﻟﺒﻴﺎﻧﺎت-1 C# private SqlConnection cn = new SqlConnection(); public void OpenConnection(string connectionString) { cn.ConnectionString = connectionString; cn.Open(); } public void CloseConnection() { cn.Close(); } ﻛﻮد 452 VB Private cn As New SqlConnection() Public Sub OpenConnection(ByVal connectionString As String) cn.ConnectionString = connectionString cn.Open() End Sub Public Sub CloseConnection() cn.Close() End Sub ﻛﻮد . ﺳﻴﻨﺎرﻳﻮ ﻋﻤﻠﻴﺔ اﻟﺤﺬف-2 ً ^3 o&'\ אfW אو، :F. o&'\ אfW אو، : o&'\ אfW م$+F N F אlWS U KFDC$3 وOverLoading אلC$3אم$+א03ً ^3وQ אوK.אوא4אz'אhאHIאi$وFא9$ .7وسHدUFg, אنWًوאMQאEnums א234 אU g3א$+ א5P> tوאل א$ אK KFD S \ אlWS U Fg3 אنª9 *** :fא(و53f& C# public void DeleteEmployee(int id) { string sql = string.Format("Delete from Employee where ID = {0}", id); using(SqlCommand cmd = new SqlCommand(sql, this.sqlCn)) { try { cmd.ExecuteNonQuery(); } catch(SqlException ex) { Exception error = new Exception("some error occures: ", ex); throw error; } } } ﻛﻮد 453 public void DeleteEmployee(string name) { string sql = string.Format("Delete from Employee where [First Name] = '{0}'", name); using(SqlCommand cmd = new SqlCommand(sql, this.sqlCn)) { try { cmd.ExecuteNonQuery(); } catch(SqlException ex) { Exception error = new Exception("some error occures: ", ex); throw error; } } } enum deletecondition { morethan=0, lessthan=1, equal=2 } public void DeleteEmployee(int age,deletecondition delcondition) { string sql=""; if(delcondition == deletecondition.morethan) sql = string.Format("Delete from Employee where age > {0}",age); else if(delcondition == deletecondition.lessthan) sql = string.Format("Delete from Employee where age < {0}",age); else sql = string.Format("Delete from Employee where age = {0}",age); using(SqlCommand cmd = new SqlCommand(sql, this.sqlCn)) { try { cmd.ExecuteNonQuery(); } catch(SqlException ex) { Exception error = new Exception("some error occures: ", ex); throw error; } 454 } } ﻛﻮد VB Public Sub DeleteEmployee(ByVal id As Integer) Dim sql As String = String.Format("Delete from Employee where ID = '{0}'", id) Using cmd As New SqlCommand(sql, Me.sqlCn) Try cmd.ExecuteNonQuery() Catch ex As SqlException Dim [error] As New Exception("some error occures: ", ex) Throw [error] End Try End Using End Sub Public Sub DeleteEmployee(ByVal name As String) Dim sql As String = String.Format("Delete from Employee where [First Name] = '{0}'", name) Using cmd As New SqlCommand(sql, Me.sqlCn) Try cmd.ExecuteNonQuery() Catch ex As SqlException Dim [error] As New Exception("some error occures: ", ex) Throw [error] End Try End Using End Sub enum deletecondition { morethan=0, lessthan=1, equal=2 } Public Sub DeleteEmployee(ByVal age As Integer, ByVal delcondition As deletecondition) Dim sql As String = "" If delcondition = deletecondition.morethan Then sql = String.Format("Delete from Employee where age > {0}", age) ElseIf delcondition = deletecondition.lessthan Then sql = String.Format("Delete from Employee where age < {0}", age) Else sql = String.Format("Delete from Employee where age = {0}", age) End If 455 Using cmd As New SqlCommand(sql, Me.sqlCn) Try cmd.ExecuteNonQuery() Catch ex As SqlException Dim [error] As New Exception("some error occures: ", ex) Throw [error] End Try End Using End Sub : ﺳﻴﻨﺎرﻳﻮ ﻋﻤﻠﻴﺎت اﻻﺿﺎﻓﺔ واﻟﺘﻌﺪﻳﻞ-3 .قi$!s9אوאhאHIi$KQ$ א5P>7Q1@אON .a7! Iאولوא9لאI אدnDl4`N!s9אFN .a7!אول9א.א9$ل$N ًN35P و،iH'V@אON'نPQنCًMQCqNQKQ$وא C# public void InsertEmployee(string fname, string lname, int age) { // Format and execute SQL statement. string sql = string.Format("Insert Into Employee_info" + "([First Name], [Last Name]) Values" + "('{0}', '{1}')",fname, lname); using(SqlCommand cmd = new SqlCommand(sql, this.sqlCn)) { cmd.ExecuteNonQuery(); } } ﻛﻮد public void UpdateEmployee(int id, string newFirstName) { string sql = string.Format("Update Employee Set [First Name] = '{0}' Where ID = '{1}'", newFirstName, id); using(SqlCommand cmd = new SqlCommand(sql, this.sqlCn)) { cmd.ExecuteNonQuery(); } } 456 ﻛﻮد VB Public Sub InsertEmployee(ByVal fname As String, ByVal lname As String, ByVal age As Integer) ' Format and execute SQL statement. Dim sql As String = String.Format("Insert Into Employee_info" + "([First Name], [Last Name]) Values" + "('{0}', '{1}')", fname, lname) Using cmd As New SqlCommand(sql, Me.sqlCn) cmd.ExecuteNonQuery() End Using End Sub Public Sub UpdateEmployee(ByVal id As Integer, ByVal newFirstName As String) Dim sql As String = String.Format("Update Employee Set [First Name] = '{0}' Where ID = '{1}'", newFirstName, id) Using cmd As New SqlCommand(sql, Me.sqlCn) cmd.ExecuteNonQuery() End Using End Sub . ﺳﻴﻨﺎرﻳﻮ ﻋﻤﻠﻴﺎت اﻟﺒﺤﺚ-4 אلFD Sم وS z, gV7NQ 7وאل א$ ن אT نC 'د، R אFD 'QHN U z$ אK. U،a7!s'7^א39א5P، Sql Injection אل5D{NאKT\ אU Parameters .PT\אlWSKLlNF31NאنRאFD Data UG13CnN9،Y3 ID .ص+, Iאولوא9 א5Di$وאrFDX`N א مB n P جd 9 P 234 אhFD 2343 g%d $. t אh1 אK KFLayer .i$وא : Stored Procedure KFً9'مאو7N SQL Server ﻛﻮد 457 CREATE PROCEDURE GetFirstNameByID @id int, @fName char(10) output AS SELECT @fName=[First Name] from Employee_info where ID > @id :אKPTRאFbאא$אoQ'م753و C# public string SelectName(int id) { using (SqlCommand cmd = new SqlCommand("GetFirstNameByID", cn)) { cmd.CommandType = CommandType.StoredProcedure; SqlParameter param = new SqlParameter(); param.ParameterName = "@id"; param.SqlDbType = SqlDbType.Int; param.Value = id; param.Direction = ParameterDirection.Input; cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@fName"; param.SqlDbType = SqlDbType.Char; param.Size = 10; param.Direction = ParameterDirection.Output; cmd.Parameters.Add(param); cmd.ExecuteNonQuery(); return cmd.Parameters["@fName"].Value.ToString(); } return carPetName; } ﻛﻮد VB Public Function SelectName(ByVal id As Integer) As String Using cmd As New SqlCommand("GetFirstNameByID", cn) cmd.CommandType = CommandType.StoredProcedure Dim param As New SqlParameter() param.ParameterName = "@id" param.SqlDbType = SqlDbType.Int param.Value = id param.Direction = ParameterDirection.Input cmd.Parameters.Add(param) ﻛﻮد 458 param = New SqlParameter() param.ParameterName = "@fName" param.SqlDbType = SqlDbType.Char param.Size = 10 param.Direction = ParameterDirection.Output cmd.Parameters.Add(param) cmd.ExecuteNonQuery() Return cmd.Parameters("@fName").Value.ToString() End Using End Function אم$+9אU،153^א03gqTنFMVON3 dll Un DataLayer אلKV!NP>ً79 -1 و، myDataLayer 9 אKF DataLayer h א71 Class JOאض אن אZ! אnD ً و79 :אK^35Q1'SN3X'1\אKfWLאK^3FD C# myDataLayer example=new myDataLayer(); example.OpenConnection(myconnectionstring); example.DeleteEmployee(10); example.DeleteEmployee("Ahmed"); ﻛﻮد VB Dim example As New myDataLayer() example.OpenConnection(myconnectionstring) example.DeleteEmployee(10) example.DeleteEmployee("Ahmed") ﻛﻮد !!!a7!و .7Q1@אONg3א$+. US אد. dll '(مN@אONو ، hא$D'א.5D$אKًא$:FD.و234'אQHN234\אb א7Q1אlWg،(9' .sوCiH'VKT\א¤Hא$نP39bوאsوCbCKFא7אنF 459 Asynchronous Data Access .7 0N\ .'@ אO U h א$D'א. nD hFD i$D KFD 53 NNe 7Q ولRN j אlWS U NH'عدs'3'SW وאDisconnected KVON\א0s'אU4אiH'VNg% 'אPT\אنא03و،XHMא :א\^لאX%،Qא`אlWSUKLאX`NNא9 ،دم7א C# SqlConnection cn = new SqlConnection(); cn.ConnectionString = @"Data Source=(local)\SQLEXPRESS;Integrated Security=SSPI;" + "Initial Catalog=AutoLot;Asynchronous Processing=true"; cn.Open(); ﻛﻮد ﻛﻮد VB Dim cn As New SqlConnection() cn.ConnectionString = "Data Source=(local)\SQLEXPRESS;Integrated Security=SSPI;" + "Initial Catalog=AutoLot;Asynchronous Processing=true" cn.Open() ConnectioString אلU Asynchronous Processing=true 0s' אoQ S g NF. i'1I ولC :وאلא$א53iدO9אnD5QHد. NRbא7Q1אlWg EndExecuteReader()وBeginExecuteReader() EndExecuteNonQuery()وBeginExecuteNonQuery() EndExecuteXmlReader()وBeginExecuteXmlReader() مאو9אB I]C$Nو، EndExecuteReader وBeginExecuteReader nDאنX`N :ً ^3@ 'אنF C# string strSQL = "WaitFor Delay '00:00:05';Select * From Employee_info"; SqlCommand myCommand = new SqlCommand(strSQL, cn); ﻛﻮد VB Dim strSQL As String = "WaitFor Delay '00:00:05';Select * From Employee_info" ﻛﻮد 460 Dim myCommand As New SqlCommand(strSQL, cn) :I$QnDAIChFDWON'م7NNS ﻛﻮد C# IAsyncResult itfAsynch; itfAsynch = myCommand.BeginExecuteReader(CommandBehavior.CloseConnection); ﻛﻮد VB Dim itfAsynch As IAsyncResult itfAsynch = myCommand.BeginExecuteReader(CommandBehavior.CloseConnection) $Q^אWON53zg9אnhFאWONو C# while (!itfAsynch.IsCompleted) { // ً ^3,p3F. q . ﻛﻮد Thread.Sleep(1000); } VB While Not itfAsynch.IsCompleted ' ً ^3,p3F. q . ﻛﻮد Thread.Sleep(1000) End While .S$QtאFאWON'م7Nאن،אولWONאzgאcQאWg!7 אLoop אل53N%INC}אن C# SqlDataReader myDataReader = myCommand.EndExecuteReader(itfAsynch); while (myDataReader.Read()) { MessageBox.Show(myDataReader[0].ToString()); } myDataReader.Close(); ﻛﻮد VB ﻛﻮد 461 Dim myDataReader As SqlDataReader = myCommand.EndExecuteReader(itfAsynch) While myDataReader.Read() MessageBox.Show(myDataReader(0).ToString()) End While myDataReader.Close() Transactions .8 א\^ل،Q'o.'وCQ'نC$9hFא53D'F'د%'وS$Q$,HVI FאlWSoQ .2KFD1KFD53PNאKQ'RאhFDSFאlWkg,א :אKPT 'نPنC$9hא$D'א.UKFאh'א1IאW .1KFDX53H9دو500GR .2KFDXUH9دو500אع$Qאً ^3لV9ع א179^אFאوو_אFאe'nN}،Q'אن$9 نFنאSو fQ3'SوAIدونאgN3 FDאfWوCYFدאFDאQאن$9אW،'ل73 אWg! .roll back nD DBMS hאi$D.(مUhFא53D'F¡אlWSoQ transaction KFNF. ذא .Q'SWONم$DאوQ'SWONQri$وאi$وKP, z ل א5Fs i'د%'\ אSqlTransaction JO אS NQ$ F אlWS 5D وp\ אJOא :K^3ًMQ א.net zCل5FsFאlWS1gNP> AIChJ!¤NS،System.Data.SqlClient lWSUD$אNم$7t אCOM+ h'P303لV9אJOאlWSN:System.EnterpriseServices .Fא . transactionsאلD$h71zN JOאlWSN :System.Transactions .ً MQ אtransaction د¨אل3 153نJOنאSNNPe : WWF وWCF KF 'م7Q Stored ProcedureoQ Q 5D Fg\ אlWg م7 אNP> h א$D'א. ( U n 462 53'عNאאWSUz$אNP>،COMMIT وROLLBACK وTRANSACTION Q5D transactions :NS رابط http://msdn.microsoft.com/en-us/library/ms187844.aspx W وאIDbTransaction interfaceg% א'א1 t אDBTransaction JO אNQ$ ADO.net U :אjوאلא$אnD'd C# public interface IDbTransaction : IDisposable { IDbConnection Connection { get; } IsolationLevel IsolationLevel { get; } void Commit(); void Rollback(); } ﻛﻮد VB Public Interface IDbTransaction Inherits IDisposable ReadOnly Property Connection() As IDbConnection ReadOnly Property IsolationLevel() As IsolationLevel Sub Commit() Sub Rollback() End Interface ﻛﻮد Ug'ع%אQ17ªONt وאSave Si$Q$% دאSqlTransaction אلNoMQ Kא3nDFو אCFא53zא%א¤NS'ن−K3PFאU'ع%لא$Fمאe אUKTOא (א\'دع£\ א− KF)אאnD'dول$% 'د%אضوZ!'אS ،F אlWS1nD^ل3aא :אKPTF'م7IX53KQ' F'م73$NDو C# SqlCommand cmdGet = new SqlCommand("update customers set total=total-" + totalmoney.ToString() + " where ID" + custID.ToString(), cn); cmdSelect.ExecuteNonQuery(); SqlCommand cmdSet = new SqlCommand("update customers set total=total+" + totalmoney.ToString() + " where ID" + SuppID.ToString(), cn); cmdSelect.ExecuteNonQuery(); ﻛﻮد 463 VB Dim cmdGet As New SqlCommand("update customers set total=total-" + totalmoney.ToString() + " where ID" + custID.ToString(), cn) cmdSelect.ExecuteNonQuery() ﻛﻮد Dim cmdSet As New SqlCommand("update customers set total=total+" + totalmoney.ToString() + " where ID" + SuppID.ToString(), cn) cmdSelect.ExecuteNonQuery() N]h אi$D.(مHIولאRNאW،Fא53^אzאo.'Q$.نG وFאlWSU .i,3AIאzq אFgN3i$وאWONQ_'و،.'@אOUYF אWONN C# SqlCommand cmdGet = new SqlCommand("update customers set total=total-" + totalmoney.ToString() + " where ID" + custID.ToString(), cn); SqlCommand cmdSet = new SqlCommand("update customers set total=total+" + totalmoney.ToString() + " where ID" + SuppID.ToString(), cn); SqlTransaction sqltr = null; try { sqltr = sqlCn.BeginTransaction(); cmdGet.Transaction = sqltr; cmdSet.Transaction = sqltr; cmdGet.ExecuteNonQuery(); cmdSet.ExecuteNonQuery(); if (throwEx) { throw new ApplicationException("all operation canceld, some errors occures"); } sqltr.Commit(); } catch (Exception ex) { MessageBox.Show(ex.Message); tx.Rollback(); } } ﻛﻮد VB Dim cmdGet As New SqlCommand("update customers set total=total-" + totalmoney.ToString() + " where ID" + custID.ToString(), cn) ﻛﻮد 464 Dim cmdSet As New SqlCommand("update customers set total=total+" + totalmoney.ToString() + " where ID" + SuppID.ToString(), cn) Dim sqltr As SqlTransaction = Nothing Try sqltr = sqlCn.BeginTransaction() cmdGet.Transaction = sqltr cmdSet.Transaction = sqltr cmdGet.ExecuteNonQuery() cmdSet.ExecuteNonQuery() If throwEx Then Throw New ApplicationException("all operation canceld, some errors occures") End If sqltr.Commit() Catch ex As Exception MessageBox.Show(ex.Message) tx.Rollback() End Try WONאWطوTאUKI$5!]1ICE$d_3و، transaction אلFDz$'م7،(9F throw Exception 3'م7N!]1IאEو$U3C،FSدFDوאYFאWON Commit دא t אh א] א0B zq אK% א53 rollback א$ אzD$ ¤NS 'م7N Catch i,3 N7NQ Wوא .$ .E$d3X% وthrowEx=trueF.K%X%،:و$O!\אא\^لWS {'دN' ^אFאU]1I'د%مو$DU3C،]_ ً ^3 1KFא£3F.אن$`^אن3%' .2KFD1KFD53g7$.£\ א53iد$[אFPאنא$`! ﻣﻼﺣﻈﺔ ولאو$%¤NS'نPiאدUK ،KPTאאWgfVאعوא$Q9'ن(مאPQ5Q$א71Uً .:! IوGRوfbאعو$Qא53 KFDKPlא¡אhFאnD'dول$%53^א 465 اﻟﻮﺿﻊ اﻟﻤﻨﻔﺼﻞ .9 ]TNQ W'אS وconnected layerKV\ א0s' א5D ADO.net N7 U N^Q$V. א7 אNوH دU N:3$7Wא^אzא،ً(Lg! Q$0B prhאi$D.YوNi,31אH i$D. 03 K3 FQ W وאdisconnected layer KVON\ א0s' א1 P3 אS N7 אlWS .hאi$D. i$وאi3h Q$!אK753وhJOא53D'FQ5DiאWאU hא zT א53 و، 234 אY وh אi$D. Y a'ن وPQ DataAdapter KFD Q 5D ذQ .hאi$D.AICi3kH אgDKFאQDataSet . DataColumn وDataRow hNjnD' DataTable 53د$DCnD DataSet 'אل i$D.gOS DataSet !ل،hi$D.03لV9א53א'ع:!مQ90s'אאWS]نW אن7 אWSQgUAICi3g!'دh i$D7لVدونאאQא$אUNوHدKb'אNאWh .7א DataSet اﻟـ.9.1 hQ'[א،−.p3−iאWאU5Pوh$D'א.(مN iH'b5DiHDS DataSet אل$Q$,HVI :SJOאlWkא : אhJOא .i$D7אlWSUאول$ א:DataTableCollection .O+\אولא$אYh. א:DataRelationCollection DataSet .*אلjVI!s9:PropertyCollection :*אjVא 466 .9א:DataSetName ،hQ'RF serialize KFDgQtא7Q1א$Q$:RemotingFormat .l אوXML אوbinary K^3 :وאلא$א AcceptChanges KFD i3IWN3 DataSet אلnDetאh אqא1:AcceptChanges() .hאi$D.k KFD i3 I WN3 DataSet אلnD e t אh Q$ א0B zq א: RejectChanges() .kAcceptChanges DataSet .אلhQ')!3:Clear() h. אولوא$אg!}hאi$D7 structure KPkא¢:Clone() .hא0B !sאKPkא¢:Copy() AcceptChanges KFDi3IWN3 hאi$D7$tאh אq!!א3: GetChanges() .k KFD i3 I WN3 e $. h אq ¤NS אذאF! $Q$ Boolean F. : HasChanges() .9אمAcceptChanges . DataSet i$D23د:Merge() DataSet אل53 XML KP,nDizא7وאP א: WriteXml() وReadXml() : DataSet اﻧﺸﺎء :אKPT 7Qa'دPאQ5D DataSet zTאNP> C# DataSet empDataSet = new DataSet("My Employee"); ﻛﻮد VB Dim empDataSet as DataSet = New DataSet("My Employee") ﻛﻮد 467 g(وgR. DataSet $` Data hאدوאFj.53، .net hدوאCQ5DSzTאNP>وC :אKPTi,3©\א DataTables اﻟﺘﻌﺎﻣﻞ ﻣﻊ.9.2 :S:אbN*وאjVא،i$FDCوf'ObnD ً 79'RWوא9אVN'אSول$א .ول$אKPS¢:Copy() Table .אאلWSnD'dW אDataSet אل:DataSet .ول$אאWk PrimaryKey אل:PrimaryKey .ول$אא:TableName .ول$אאWSgQ'dtאh. א:ParentRelations DataTable اﻧﺸﺎء.9.3 C# DataTable EmployeeTable=new DataTable(); EmployeeTable.PrimaryKey = new DataColumn[] { EmployeeTable.Columns[0] }; ﻛﻮد VB Dim EmployeeTable As New DataTable() ﻛﻮد 468 EmployeeTable.PrimaryKey = New DataColumn() {EmployeeTable.Columns(0)} : DataSet إﻟﻰDataTable اﺿﺎﻓﺔ C# empDataSet.Tables.Add(EmployeeTable); ﻛﻮد VB empDataSet.Tables.Add(EmployeeTable) ﻛﻮد DataColumns اﻟﺘﻌﺎﻣﻞ ﻣﻊ.9.4 KPT DataColumns אل53 D'F !¦نI nN} و، h אi$D. U $'د وאFD JO אlWS K^e :SJOאlWkאh'P\א،h אi$D.KPSnD'dDataTable ob'א bא F7 אnD 'دFאאWSU7אzمא'א$vFא$Q$R AllowDBNull Null F j7 . bI KFD E ^* אjV אlWS $Q$R م$+ و، SQL Server 5D NH دوQא$ U SNRsאو GZ אnDi3K03iدQאHא$73وQא$א17$Q$وbא AutoIncrement AutoIncrementSeed AutoIncrementStep 'دFאא Caption h'ع א DataType 'دFאאWSU'ل7Lא7sאZ!9אF7א DefaultValue 'دFאאWS:0QW אDataTable אل$Q$ Table Primary keyHאP. F7אlWS د'ن$ Unique : : DataColumns اﻧﺸﺎء 9Fg!Fوא9א3C،j7.ًMQوאjHvO3'S Wא.אnD'hi$D.zTضאZON :ول$אאWSUi$FDאKP,'SאWS'نP،i .CnDنQ'd 469 C# DataColumn EmpIDColumn = new DataColumn("ID", typeof(int)); EmpIDColumn.Caption = "Employee ID"; EmpIDColumn.ReadOnly = true; EmpIDColumn.AllowDBNull = false; EmpIDColumn.AutoIncrement=true; EmpIDColumn.AutoIncrementSeed=1; EmpIDColumn.AutoIncrementStep =1; EmpIDColumn.Unique = true; DataColumn EmpNameColumn = new DataColumn("Name", typeof(string)); EmpNameColumn.Caption = "Employee Name"; DataColumn EmpAgeColumn = new DataColumn("Age", typeof(int)); EmpAgeColumn.Caption = "Employee Age"; ﻛﻮد VB Dim EmpIDColumn As New DataColumn("ID", GetType(Integer)) EmpIDColumn.Caption = "Employee ID" EmpIDColumn.[ReadOnly] = True EmpIDColumn.AllowDBNull = False EmpIDColumn.AutoIncrement = True EmpIDColumn.AutoIncrementSeed = 1 EmpIDColumn.AutoIncrementStep = 1 EmpIDColumn.Unique = True Dim EmpNameColumn As New DataColumn("Name", GetType(String)) EmpNameColumn.Caption = "Employee Name" Dim EmpAgeColumn As New DataColumn("Age", GetType(Integer)) EmpAgeColumn.Caption = "Employee Age" ﻛﻮد :אKPT DataTable אلgOM53و C# EmployeeTable.Columns.AddRange(new DataColumn[] { EmpIDColumn, EmpNameColumn , EmpAgeColumn }); ﻛﻮد VB EmployeeTable.Columns.AddRange(New DataColumn() {EmpIDColumn, EmpNameColumn, EmpAgeColumn}) ﻛﻮد 470 DataRows اﻟﻌﻤﻞ ﻣﻊ.9.5 :SJOאlWkjאh'P\א،f'OVא03K3 JOאlWS*§ ob'א bא objectsאل53 array !'OV3KP,nDoVאאWSh! ItemArray oVאאWSnD'dWولא$א Table oVאאWSnDetאh אq א1 AcceptChanges() zD$ אi3I WN3 oVא אWS nD e t אh אq אzqא RejectChanges() g!AcceptChanges() oVאאWSnDKQ$אFD z$ BeginEdit() h Q$אªOوKQ$אFDzgא EndEdit() KQ$אFDzqא CancelEdit() AcceptChanges()zD$א$NDoVאאWSfW Delete() 9 אمnull SKSوoVאאWSU3'دFDF.!\ IsNull() nF\ אenum אل53 gzא. 5P> t وאoV א RowState DataRowState :א7אnD−DataRowState–'dWوא 471 : DataRows اﻧﺸﺎء :]1I]TNQf'1אאWSK^3،i,3 DataRows zTא5P>9 C# DataRow r = new DataRow(); ﻛﻮد VB Dim r As DataRow = new DataRow(); ﻛﻮد . 0s ووDataRow 53 + zT9 א א\^لWS ، ول$ א53+ 53 DataRow zT א53 $ 9 5P .Qא$אU:FNF.Wولא$אGg!f'OVא C# DataRow EmpRow = EmployeeTable.NewRow(); EmpRow["Name"] = "Ahmed Gamal"; EmpRow["Age"] = 22; EmployeeTable.Rows.Add(EmpRow); EmpRow = EmployeeTable.NewRow(); EmpRow[1] = "Ahmed Essawy"; EmpRow[2] = 23; EmployeeTable.Rows.Add(EmpRow); ﻛﻮد VB Dim EmpRow As DataRow = EmployeeTable.NewRow() EmpRow("Name") = "Ahmed Gamal" EmpRow("Age") = 22 EmployeeTable.Rows.Add(EmpRow) EmpRow = EmployeeTable.NewRow() EmpRow(1) = "Ahmed Essawy" EmpRow(2) = 23 EmployeeTable.Rows.Add(EmpRow) ﻛﻮد 3א9'ل7R 'لb'אg!אوLאنאF،j7. :ً (אID K7Lא0M_N( א9' . Index אل.4!^א وﻣﻌﺮﻓﺔ اﻟﺼﻔﻮفDataSet ﻣﻌﺮﻓﺔ ﻛﻞ اﻟﺠﺪاول ﻓﻲ ﻗﺎﻋﺪة اﻟﺒﻴﺎﻧﺎت: ﻣﺜﺎل ﺷﺎﻣﻞ:واﻷﻋﻤﺪة 472 C# Text1.Text=""; foreach (DataTable dt in empDataSet.Tables) { Text1.Text+=dt.TableName + ":\n\r"; for (int curCol = 0; curCol < dt.Columns.Count; curCol++) { Text1.Text+= (curCol+1).ToString() + dt.Columns[curCol].ColumnName+"\n\r"; } Text1.Text="Rows: \n\r"; for (int curRow = 0; curRow < dt.Rows.Count; curRow++) { for (int curCol = 0; curCol < dt.Columns.Count; curCol++) { Text1.Text+= dt.Rows[curRow][curCol].ToString() + " - "; } } } ﻛﻮد ﻛﻮد VB Text1.Text = "" For Each dt As DataTable In empDataSet.Tables Text1.Text += dt.TableName + ":" & Chr(10) & "" & Chr(13) & "" For curCol As Integer = 0 To dt.Columns.Count - 1 Text1.Text += (curCol + 1).ToString() + dt.Columns(curCol).ColumnName + "" & Chr(10) & "" & Chr(13) & "" Next Text1.Text = "Rows: " & Chr(10) & "" & Chr(13) & "" For curRow As Integer = 0 To dt.Rows.Count - 1 For curCol As Integer = 0 To dt.Columns.Count - 1 Text1.Text += dt.Rows(curRow)(curCol).ToString() + " - " Next Next Next ﻟﻘﺮاءة اﻟﺒﻴﺎﻧﺎت ﻣﻦDataTableReader اﺳﺘﺨﺪام.9.7 DataTable C# Text1.Text=""; DataTableReader dtReader = dt.CreateDataReader(); ﻛﻮد 473 while (dtReader.Read()) { for (int i = 0; i < dtReader.FieldCount; i++) { Text1.Text+= dtReader.GetValue(i).ToString(); } } VB Text1.Text = "" Dim dtReader As DataTableReader = dt.CreateDataReader() While dtReader.Read() For i As Integer = 0 To dtReader.FieldCount - 1 Text1.Text += dtReader.GetValue(i).ToString() Next End While ﻛﻮد XML إﻟﻰSerializing ﻋﻤﻞ .10 C# EmpDataSet.WriteXml("Employee.xml"); ﻛﻮد VB EmpDataSet.WriteXml("Employee.xml") ﻛﻮد :@PوאC C# EmpDataSet.ReadXml("Employee.xml"); ﻛﻮد VB EmpDataSet.ReadXml("Employee.xml") ﻛﻮد :ً Q7KPTאאWg Employee.xml o\א2'نP ﻛﻮد <?xml version="1.0" standalone="yes"?> <Employee_XML> 474 <Employee> <ID>1</ID> <Name>Ahmed Gamal</Name> <Age>22</Age> </Employee> <Employee> <ID>2</ID> <Name>Ahmed Essawy</Name> <Age>23</Age> </Employee> </Employee_XML> DataGrid اﺳﺘﺨﺪام ال .11 DataGridView iאدאGR'SD3K،YO&'\ولא$%:!Ns ً وو7lzTNF.WאNDوT3U :אKPTi'د%'\ אhאدوא5Fs53 New !s אHI . ، Choose DataSource Q 5D H$V\ h אi$D. aH 'S ND 3 K .Nbאh אi$D.HI'م753 وDataBase !sא،©\א0.و،DataSource ﻣﻼﺣﻈﺔ وאض אلDataSource KF 'م. אConnectionString אل5D r א53 9 ً $ i אدU gjq 'م.א،ConnectionString t مא9אBوCول$אHI¤4§,, g(،سH'א$אHIbא,Tאzgא$ X`N9^ل3Uو،YO&'\ولא$%'S وi,3ول$%HIאX`N ،ول$אUg(نCk'د . א مBHIא 475 :אWSK^3ًJ,2N'نאP .ول$א53!s9وאKQ$bOאאNP> 01 =אول9אktאA'hضאDQ9rRط,1N،ًא$% a KQ$X`Nאن א مB G א53 وAdd Query ZI אdataGrid אل53 ، * 03 U 'د%'\א אول א : 476 :2jNא$S,وQgNאn9אX%،אKPTnDאU,,H'g& ª ؟KאWPS53Kgא$%'Q KS DataAdapter اﺳﺘﺨﺪام .12 :لאPT DataAdapter oQ.،i$Q$, C# string connectionString = @"Data Source=AHMED-PC\SQLEXPRESS;Initial Catalog=Employee;Integrated Security=True;Pooling=False"; ﻛﻮد DataSet ds = new DataSet("Employee"); SqlDataAdapter dAdapt = new SqlDataAdapter("Select * From Employee_info", connectionString); dAdapt.Fill(ds, "Employee_info"); ﻛﻮد VB Dim connectionString As String = "Data Source=AHMED-PC\SQLEXPRESS;Initial Catalog=Employee;Integrated Security=True;Pooling=False" Dim ds As New DataSet("Employee") Dim dAdapt As New SqlDataAdapter("Select * From Employee_info", connectionString) dAdapt.Fill(ds, "Employee_info") 477 اﻟﺒﺎب 18 LINQ .O+\אhא$D'א.03g3gNi\אlWS،LINQ03AICi3'دN 478 479 ﻣﻘﺪﻣﺔ .1 Language Integrated N7nDfNHو$אz%، ADO.net _DUط7NאnDN!אن$ سHدUNOאFf$g!'وPQ3 53i$Q$%N7Sو، LINQ ًאHVIאfQ3 אوQuery B $' ذos א، 'Q !`'אل 'دJ لI 53 g! PR א5P> Q'. h3 אzN o3وC XML File وChi$D.نz'א:3K3Wאhא$D'א.H$V3 D'5PFg3 م9א .:! IوCKאo3 אوV :Sgjא%C nDfولאRNjHא'אعE LINQ K LINQ to SQL −1 LINQ to XML −2 LINQ to Objects−3 U lN, Wض א\^ل אZON ، Array 'ع53 q3 i,3 م9 אS م9'אع אC aC :אKPTوسHدi$DK. LINQ N3$73 ﻛﻮد from d in developers where d.Language =="C#" select d.Name; : אKPTgPNt مא9אBgOSlWS ﻛﻮد select name from developers where language=’C#’ nDg71 NP3Hb K،gDlWS م9אBWONhi$D.'د%' ج$_אن5Pو :אKPT!'OV3 480 C# public class Developer { public string Name; public string Language; } Developer[] developers = new Developer[] { new Developer { Name = " Ahmed", Language="C#" }, new Developer { Name="Khaled", Language="Java", new Developer { Name="Ali", Languag="C++"} }; ﻛﻮد ﻛﻮد VB Public Class Developer Public Name As String Public Language As String End Class Dim developers As Developer() = new With { New Developer { .Name = " Ahmed", .Language="C#" }, New Developer { .Name="Khaled", .Language="Java", New Developer { .Name="Ali", .Languag="C++"} } :אKPT1 א مBGP 53و C# IEnumerable<string> LINQresult = from d in developers where d.Language =="C#" select d.Name; ﻛﻮد VB Dim LINQresult As IEnumerable(Of String) = From d In developers Where d.Language ="C#" Select d.Name ﻛﻮد :אKPT2NאDKPP3bCو C# foreach ( string s in LINQresult ) { MessageBox.Show(s); } ﻛﻮد 481 VB For Each s As String In LINQresult MessageBox.Show(s) Next ﻛﻮد ج93د3RRbF`! ،:3$Dאو7אh 3\א53K33אمא$+אNP>ª F :طTא C# IEnumerable<string> LINQresult = from d in developers select d.Name; ﻛﻮد VB Dim LINQresult As IEnumerable(Of String) = From d in developers Select d.Name ﻛﻮد :אKPT'ل1 دאאK^3طTא5FsQدD.netאمدא$+ًאMQאNP>F C# IEnumerable<string> LINQresult = from d in developers where d.Name.Length > 3 select d.Name orderby d.Name; ﻛﻮد VB Dim LINQresult As IEnumerable(Of String) = From d in developers Where d.Name.Length > 3 Select d.Name Orderby d.Name ﻛﻮد : ﺗﺮﺗﻴﺐ ﺟﻤﻞ اﻻﺳﺘﻌﻼم S'نP Select م$+ LINQUNNPو، Select From Where GnD م9 אKBU'د `'אلO אnD $F 'د אنN אIntelliSense fQ 3 'S KP G א، ً Fj دאi Iא 482 `'אلO א01Q 5! From K. Select N ' F! ، N H'g( אgNP> t אi$FD אN g( 'Q'د .$:N3C7نC$Qول$%אfQ9:i'د%'\אhאHא$Q$U$D3 'Q'د :3P مא9אB ﻛﻮد from id in source { from id in source / Join id in source on expr equals expr [into id] | Let id = expr | Where condition | Orderby ordering, ordering, … [Ascending | Descending] } Select expr | Group expr by key [into id query] …אz,وسنH$אlWSUNFD لIgDfN،a7!U3אqVאlWS0s LINQ دوال .2 53D'F¡אlWShو,و3nD fولאنאRN،OO& دوאوو51nD LINQ' .NوH لدIgN3ًMم$+Ntوאلوא$א ob'א א$א وCgsوCم.HCi$D0Bً ^3،LאhFHP\א1 Aggregate :א\^لא،FDC int product=ints.Aggregate(1, (a,b)=> a* b ); .م.Hא53!'OV3SintsنC KS!3'دCً ^3ضZON،KPאnDط,1A$3!\ All :9مCY%و3YO&'\אK bool isMarried=employees.All(emp=>emp.statues==1); a7!$'نوאURRbF.$g!،7@אPDnD Any 483 :אא\^لWS،طTא7dD'F¡א53K.אnD bool isMarried=employees.Any(emp = > employees.statues==1); :אא\^لWS،7א53D'F¡a'\א Average double avg=ints.Average(); .م.Hא53D'FSintsنC :אא\^لWS،د$)'عbNא53D'FKQ'R Cast var newString=ints.Cast<string>(); .م.Hא53D'FSintsنC : query2 ` و: query1 NQ$ ^ ً ' نF! ، 5QVND 23$ Concat :א3אمא$+א5P>gو'ددAIC` var result=query1.Concat(query2); $F): אo&'35DRً ^3،!'OV3KIدאRم$+ Contains :א1אGP bool find=employees.Contains(new employee(“Mohammed”); .دDQueryQ5DذKF:gT3Sو :5PQ3ًQCوC!'OV\אbNDد$DوCא م2j$'م7Q Int count = employees.Count(); :ksאZ!אF.0s!وH!F.¤NSذא Count DefualtIfEmpty var result=ints.DefualtIfEmpty(100); ً ^3 ، h'ع אN sאZ!9 אF7 א0s ! وS$Q$ Q _ ' .Objectnull'صوVN""مو.H Ob :ً ^3،hאHאPCون$hאiدD'م7Q Distinct var pure=query.Distinct(); :ً ^3،Y3نP3UF7אiدD'م7Q ElementAt Employee newemp=query.ElementAt(4); ` אنYU 4.HGP$.Cא\^لאU(9' ElementAtOrDefualt U :C אF א4§ אW ، ً bC f'Ob 0HC $ _ א م وCJOsאZ!9א7:NDs9אQ'د%'3 .'نא :h'عאN Employee newemp=query.ElementAtOrDefualt(4); :ً ^3אKPT،bNא53H!D'F'مج7Q Var newresult=System.Query.Sequence.Empty<employee Empty 484 >(); :ن713FgC53$]א موאt`YH7\א EqualAll bool iseuql=query1.EqualAll(query2); D'F¡אUi'د%'\א7عא%ZوאbNא53YD'FH73 Except :^אD'F¡אU'نPنCאودون var result=query1.Except(query2); ...hאHאPون$'نP2Nא :D'F¡אUVNDولCiدD'م7Q First employee firstone=employees.First(); .H!lWSbNאD'F'نP9نC$9*** ولCiدD!،D!א مUVNDولC$QنCًMQC5P>F :وج3o&'3 employee firstone=employees.First(emp => emp.ismarried==1); م9وאCH!D'F¡'نאU:Cא$D3אK^3 FirstOrDefault :sאZ!9אF7א$QنC`N$Q_DOא employee firstone=employees.FirstOrDefault(emp => emp.ismarried==1); AggregateאلK^3 Sql אلU1אGroupByK^3،$Q$RאGbNא0F{ Fold GroupBy :אא\^لWS،Statement var newGroup=employees.GroupBy(emp => emp.Countery); .bאlWS4D:'لb'א5P>وkeynFQو .JoinאلFD GroupJoin :a7!YD'F¡ אUi'د%'\אbNא،YD'F07 Intersect var inter=query1.Intersect(query2); .Sql StatementsUinnerjoinאلFD Join :VNDI$gNPوFirstK^3 Last Employee lastone=employees.Last(); Employee lastone=employees.Last(emp => emp.Countery==”Egypt”); م9وאCH!D'F¡'نאU:Cא$D3אK^3 LastOrDefault 485 :sאZ!9אF7א$QنC`N$Q_DOא employee firstone=employees.LastOrDefault(emp => emp.ismarried==1); :אא\^لWSLong'عNא53'نPQ2Nא5PوCountK^3 LongCount long empCount=employees.LongCount(); :D'F¡אUF.VND4C Max int num=ints.Max(); وسHدUNFFhJOאYhH7\\!א7Q$Q$5P>و 7 :D'F¡אUF.VNDqbא Min int num=ints.Min(); وسHدUNFFhJOאYhH7\\!א7Q$Q$5P>و 7 a7!intאلbNאجא+9،a7!Y3'ع53bNאجא+א OfType :GPً ^3 var newResult=list.OfType<int>(); :^لF'دPאאWS(ًQ$DV)N37QG2jNאGZ OrderyBy Var orderlist=employees.OrderBy(emp => emp.Age); :אא\^لWS،زNiH'V5PوGZא OrderyByDescending Var orderlist=employees. OrderyByDescending (emp => emp.ID); :YN35Q$YRRVمא.Hא53D'F$' Range var newlist=System.Query.Sequence.Range(1,5); :hא3@¾"1".HHאPً ^3،hא3i$DY3.HHאP Repeat var list=System.Query.Sequence.Repeat(1,5); :D'FCG@PD Reverse Var revList=list.Reverse(); :KPא5DQنC5P>،QאدRאB Select var newSelect=list.Select( emp => emp); a7!N3zא%CوC var newSelect=employees.Select( emp => new {emp.Name , emp.Age}); ،a7!ًא$ًوאOb'نPQ52N!¦نאGroupلN3א$+אU :אKPTSelectManyم$+W var newSelect=groupedlist.Select( l => l); SelectMany 486 :l nDD'F¡'א9CطTa7!i$وאF.iدDא Var result=query.Single(); C'د%مو$DUsאZ!9אF7א$Q:Cא$D@אO Single SingleOrDefault :bND Var result=query.SingleOrDefault(); bND10ولC^ ً`وز3،.אiدDوאbNא53د$D{وز Skip :7אiدDوא var newResult=query1.Skip(10); ً ^35PوY3ط,7nbNאKS`Q:NPאوK^3 SkipWhile :100אل$3.H{وز var newResult=query1.SkipWhile(x => x < 100); :D'F.0B Sum :Qא$א53Y3د$bNDع%Z'م7Q Take Double sum=ints.Sum(); var top=ints.Take(3); .Hא®دnع%Z9^ ًא3،3ط,Eو$nbNDع%Zא TakeWhile :100534א var top=ints.TakeWhile(x => x < 100); nDzNGZGZ'دאصPאUً ^3،hQ'אو$Q$R ThenBy :ً ^3G\אnDFא var orderemp=employees.OrderBy(emp => emp.Age ThenBy emp => emp.Salary); :ًزN'نPQf'i\אlWSGZنאCא$D3@אO var orderemp=employees.OrderBy(emp => emp.Age ThenByDesecnding emp => emp.Salary); :!'OV3KQ' ThenByDesecnding ToArray Employee[] emps=query.ToArray(); .אدjN!'OV3UgNQ§035P@אوO ToDictionary List<T>5jUgNQ§ ToList Lookup<K, V>5jU2Nא5Q§ ToLookup UhsHאPT3Kd03Sequence2NאKQ' ToSequence .'ل7LאzCوאلو$אYzא KKFTD'FnD2N'אd،sQدא9אFD :YD'F¡אbND Union 487 var result=query1.Union(query2); .QطאدTRאB Where ﻣﻼﺣﻈﺔ :aאאאWS53:FNP>،(LINQC$)X53אzאUً^ אh$Oא http://www.vb4arab.com/vb/uploaded/2730/11202261862.pdf : اﻟﻤﺘﻐﻴﺮات ﻏﻴﺮ اﻟﻤﻌﺮﻓﺔ: * ﺗﺬﻛﻴﺮ ﺳﺮﻳﻊ N7$j !'א53i$وאSlWS،K.53gOQ7_J!g!2N'نאPQא مBKF 'م7ًא :^لF FאlWS،ً7g,tאImplicitly Typed Local Variables ﻛﻮد var subset = from i in numbers where i < 10 select i; : LINQ ﻣﻊLambda Expressions اﺳﺘﺨﺪام: * ﺗﺬﻛﻴﺮ آﺧﺮ 7Q1 LINQ א م53ً9$ Lambda Expressions دא39hאم א$+אhD1نCW .Qאد LINQ TO DATASET .3 i$%17KPg!אW،iאWאUhאi$D.53+وCiH'bKPT NOאF dataset אل .Nb אLINQ h3 אgDم$+N hאnD'لVL وאDataTable~g1H53 وDataSetאم$+hi$D.aHX`Nً ^F! :gN3 C# DataSet ds = LoadDataSetSomeway(); ﻛﻮد 488 DataTable employees = ds.Tables["Employee"]; var query = from emp in employees.AsEnumerable() where emp.Field<Long>( "Age" ).Year >= 40 select emp; VB Dim ds As DataSet = LoadDataSetSomeway() Dim employees As DataTable = ds.Tables("Employee") ﻛﻮد Dim query = From emp In employees.AsEnumerable() Where emp.Field<Long>( "Age" ).Year >= 40 Select emp; LINQ TO XML .4 53I'عC03g3K^3 XML03K3 LINQو،ًD',h^زنאC$C אنXMLRbC .Q'gDfNtوאa7!XMLX*§t!אs*אjV!אsא،hא$D'א. :אKPTh`N\אnD'dXMLo3NsZ!^ ً'אF! ﻛﻮد <?xml version="1.0"?> <Items> <Item Number="122"> <ItemName>Item1</ItemName> <Quantity>100</Quantity> <Price>23</Price> </Item> <Item Number="123"> <ItemName>Item2</ItemName> <Quantity>10</Quantity> <Price>14.5</Price> </Item> <Item Number="124"> <ItemName>Item3</ItemName> <Quantity>31</Quantity> 489 <Price>1000</Price> </Item> <Item Number="125"> <ItemName>Item4</ItemName> <Quantity>22</Quantity> <Price>97</Price> </Item> </Items> </Items> :אKPTXMLאلo\LoadKF'م7NQא$ ﻛﻮد C# XElement purchaseOrder = XElement.Load("Items.xml", LoadOptions.SetBaseUri | LoadOptions.SetLineInfo); VB Dim purchaseOrder As XElement = XElement.Load("Items.xml", LoadOptions.SetBaseUri Or LoadOptions.SetLineInfo) ﻛﻮد :אKPT:PW'دאP'نאP،NQ$i'د%'\אfNbאD'F'دאאضNCNsZ!'א،אن C# var newSearch = from item in Items.<Item> select item.@Number ﻛﻮد VB Dim newSearch = From item In Items.<Item> Select item.@Number ﻛﻮد ^ ً؟3H9دو100534CStאD'F¡אnDH'^و C# var newSearch = from item In Items.<Item> where item.<Price>.Value > 100 select item.@Number ﻛﻮد 490 VB Dim newSearch = From item In Items.<Item> Where item.<Price>.Value > 100 Select item.@Number ﻛﻮد LINQ TO SQL .5 gDfولאRNو3א$+א^אS iאدU، SQL Server D$ًVVIg%'3 LINQ hJ!53J! .سH$אאWSUًQ : اﻟﺒﺤﺚ واﻻﺳﺘﻌﻼم $QQ 5QWص א+, i$Q$% J! KP, nD ج+ א¢QH و9 אiدD9 ً ^3 א א\^لWS ، ً 7 :D N! :V3U'نN17Q وN305DSFD C# var query = from c in Employee where c.Age > 30 && c.Countery == "Egypt" select new { c.Name, c.GraduationDate}; ﻛﻮد VB Dim query = from c in Employee Where c.Age > 30 And c.Countery = "Egypt" Select New { c.Name, c.GraduationDate}; ﻛﻮد : Stored Procedures اﺳﺘﺪﻋﺎء `'אلO אg 'م7Q 3 S و، Attributes @ אلO k Procedure :T دאoQ a7! 'S D 3 K : ( $ وאq3K7Q)א مKPTאאWg3C'S D3Kאن،ًsאZ!'אQ'د 491 C# var c = db.ProceduresName("Egypt"); ﻛﻮد VB Dim c = db.ProceduresName("Egypt") ﻛﻮد : Compiled Query 53 fQ h א$D'א. (مK% 71N\ א53 @! hא3 i$ g3$+ א مB ¤NS ذא ن hذאNم$7 LINQ ً MQC،17NאlWkKLאh א$D'א.(N!'אW،i3K م9אnD$Q$% . Compiled Query nFQ34DQ(Nא Compile KF CompiledQuery.Compileאمدא$+אnD$F Compiled Query אلiP! :^لFאKPTא، م9אF C# var c = CompiledQuery.Compile( ( DataContext context, string counteryName, int age) => from c in Employee where c.Age > age && c.Countery == counteryName select new { c.CustomerID, c.CompanyName, c.City } ); ﻛﻮد VB Dim c = CompiledQuery.Compile( ( DataContext context, string counteryName, int age) => From c in Employee Where c.Age > age And c.Countery = counteryName select New { c.CustomerID, c.CompanyName, c.City } ) ﻛﻮد KFD W م א9 אU R وא، a7! Z3H אq i3 53 ^ g3א$+ { אNP> وאن ::Compile 492 C# foreach ( var row in query(dc, "Egypt",22)) {} foreach ( var row in query(dc, "USA",28)) {} foreach ( var row in query(dc, "Saudi",38)) {} ﻛﻮد VB For Each row As var In query(dc, "Egypt", 22) Next For Each row As var In query(dc, "USA", 28) Next For Each row As var In query(dc, "Saudi", 38) Next ﻛﻮد : اﺳﺘﺨﺪام دوال ﻓﻲ ﺟﻤﻠﺔ اﻻﺳﺘﻌﻼم : مא9אBNs! ' ﻛﻮد SQL Server SELECT SUM( emp.salary ) AS TotalSalary FROM Employee emp Join Department dem ON emp.DepartmentID = dep.ID Group By dep.ID :אKPT LINQ KPTg 01 C# var c = from emp in db.Employee join dep in db.Department on emp.DepartmentID equals dep.ID into TotalSalary select TotalSalary.Sum( emp => emp.Salary ); ﻛﻮد VB Dim c = From emp In db.Employee Join dep In db.Department On emp.DepartmentID Equals dep.ID Into TotalSalary Select TotalSalary.Sum( emp => emp.Salary ); ﻛﻮد 493 : LINQ اﺳﺘﺨﺪام ﺟﻤﻞ اﻻﺳﺘﻌﻼم داﺧﻞ nD، PIVOT 3אK^3Q$7 مא9 אKBhא53i$אموא$+9ًאًא1M3O${$. : LINQ אلKI دאSQLBWONאمqVאSlWSK : - 'ل7N3^ل3 ﻛﻮد C# var query = db.ExecuteQuery<EmployeeInfo>(@" With EmployeeHierarchy (EmployeeID, LastName, FirstName, ReportsTo, HierachyLevel) AS ( SELECT EmployeeID, LastName, ForstName, ReportsTo, 1 as HierarchyLevel FROM Employees WHERE ReportsTo IS NULL UNION ALL SELECT e.EmployeeID, e.LastName, e.FirstName, e.ReportsTo, eh.HierarchyLevel + 1 AS HierarchyLevel FROM Emplyees e INNER JOIN EmployeeHierarchy eh ON e.ReportsTo = eh.EmplyeeID ) SELECT * FROM EmployeeHierarchy ORDER BY HierarvhyLevel, LastName, FirstName" ); : LINQ ﻓﻲInseret اﺳﺘﺨﺪام C# var NewEmp = new Employee { [First Name] = "Ahmed", Age = 25, Countery="Egypt"}; db.Employee.Add( NewEmp ); ﻛﻮد ﻛﻮد VB Dim NewEmp = New With { .[First Name] = "Ahmed", .Age = 25, .Countery="Egypt"} db.Employee.Add( NewEmp ) .V353وN25Fو$"C $Q$%o&'3!sNF.א\^لאU : Update اﺳﺘﺨﺪام C# var EditEmp = db.Employee.Single ( c => c.Countery == "Egypt" ); EditEmp.Age = 30; ﻛﻮد 494 VB Dim EditEmp = db.Employee.Single ( c => c.Countery == "Egypt" ) ﻛﻮد EditEmp.Age = 30 .N30VV3 53ص+,9אKFKQ$NF.א\^لאU : Delete اﺳﺘﺨﺪام C# var deleteEmp = db.Employee.Single ( c => c.Age > 50 ); db.Employee.Remove( deleteEmp ); ﻛﻮد VB Dim deleteEmp = db.Employee.Single ( c => c.Age > 50 ) ﻛﻮد db.Employee.Remove( deleteEmp ) .N505DSHFDא$Q5QW אYO&'\אfWrNF.א\^لאU SubmitChanges .6 h אqאKO db.SubmitChanges()א$אzD$א53$ 9KQ$وאCfWRوC!s FDא$ .hאi$D.U :اﻟﺘﺤﺪﻳﺚ ﺑﺎﻟﺘﺰاﻣﻦ ﻓﻲ ﻗﺎﻋﺪة اﻟﺒﻴﺎﻧﺎت W وאChangeConflictExeption5jP א:$`אW،KV\و@אKVON\א0s'K3 LINQ *אل KPT]1אHאאض5P>،Y3$+3i$DYh אi$D.nDKQ$אhFDضH5D2NQ :א 495 C# try { Db2.SubmitChanges(); break; } catch ( ChangeConflictExeption ex) { MessageBox.Show( ex.Message ); Db2.Refresh( somequery, RefreshMode.KeepChanges ); } ﻛﻮد VB Try Db2.SubmitChanges() Exit Try Catch ex As ChangeConflictExeption MessageBox.Show(ex.Message) Db2.Refresh(somequery, RefreshMode.KeepChanges) End Try ﻛﻮد .AICi3 Refresh 3C03 ولd]و1אHg(Q01Q_'،WON مא9ولאdNS :אKPTאK^3ضHEو$U234 א¤'$Q$ SubmitChanges 3אUًMQא5P> C# Db.SubmitChanges(ConflictMode.FailOnFirstConflict); Db.SubmitChanges(ConflictMode.ContinueOnConflict); ﻛﻮد VB Db.SubmitChanges(ConflictMode.FailOnFirstConflict) Db.SubmitChanges(ConflictMode.ContinueOnConflict) ﻛﻮد .5QVNא5QWSnDA''9t وאConflictMode JOא53وذ 496 ﻣﻦ ﺧﻼل اﻟﻔﻴﺠﻮال ﺳﺘﻮدﻳﻮLINQ TO SQL اﻧﺸﺎء ﻓﺌﺎت .7 ,T א53، ً 79 g PR אNP> LINQ TO SQL Classes zT א53 2008'Q`'אل 'دO אNP> :אو .אW، Server Explorer אل53hi$D.GRאوi$Q$%אول$%وh. DzTאNP>،lHI א$ :אمאKPT א$`،אول$אGRz$.وNbאhאi$D.O N ' Data Access Layer -zT אU $D} م. 'Q`'אل 'دO אن אª KP אن :ً ^3وאلא$hOQ$`،−SW 497 C# partial void InsertEmployee_info(Employee_info instance); partial void UpdateEmployee_info(Employee_info instance); partial void DeleteEmployee_info(Employee_info instance); ﻛﻮد VB Private Partial Sub InsertEmployee_info(ByVal instance As Employee_info) ﻛﻮد End Sub Private Partial Sub UpdateEmployee_info(ByVal instance As Employee_info) End Sub Private Partial Sub DeleteEmployee_info(ByVal instance As Employee_info) End Sub }H3$F)س$Ng\אXP! LINQ5D$Q\!א3'دN'، LINQXאصKVOאgCنCK. :aאאאWSnDl${،אא¡لWSUi$%Qא$ًN3'نPQ رابط http://www.vbcoffee.net/SamerSelo/linqcourseebook.pdf 498 499 اﻟﺒﺎب 19 WWF 500 501 ، WWF ًאHVI אfQ وWindows Workflow Foundation ~nFQ3!s א.net 3.0 Hא$b9אWN3 نhF אو אworkflow ~ אWON و.א3 وiH دאF API وאل$م وאg\ א53 D'F Sو . BZאRb viusal אلKIدאg!sאetאh4א$Ng\*jVא0O א53i$وאbאlWS$ً .i,3OאWONوאC'دPא03 workflows אل23ندP39 bאstudio 53234'ن אPQ،gDzN234אKPTQtאhFאD'FS Workflow אوאلWF אل مg\א53D'FnDSHو$ 't وאBusiness Process אل53אgM0313D'F .Q'KFtאوאgMYوgNVאhذא : ﻣﺜﺎل hאi$D.nD Check KFDو:F.HلIلوאدVQ9אGnD234א אWS'd:2N\Vא3$I .bلVQאDVא3$IQ$7l'د% و53$] i$D 53 'نPQ 234 وאtasks nF Iא$ אbN وאBusiness Process nF g F אlWS .Business Process 'دPً7ًوHא13gאNSi\ א5Pو، Workflow אلiאدא3$Iم$7tא23א4א53$Q$א¤NS KQ$א:P3ذאosא،h$%نوz1Iא0 وi$ nDi$وאKP trace KFD5P>r .Q'وgA4P אhjאUً79 WFﻣﻜﻮﻧﺎت واﺳﺎﺳﻴﺎت .1 hאHאP وאTאKF!אW، visio K^3Rs'h3'Hدa7!@وWONK.'دS WF אل .ً !SWONQ WF אلUi'د%'\א:! Iو .net .Kh'P3]نא,g],:! I وassemblies وnamespaces nD' WF !لGאאWkو 502 : Workflow Activity gNل79وאaKj'وQ`'אل'دOאNQ وActivities KP,nDN אصKFאob'Q :N3h'א1I KP,nDSWONQאوY3 Invoke 'لVوCiZO delay وC if else K^3אYو WF اﻟﺒﺪأ ﻣﻊ .1.1 : Empty WorkflowZI אWorkflow وعT\'عאK%א،$Q$% وعT3zT. hא$ t'אعאوא !sא،bIh7NאnD'd9غH!وعT3: Empty Workflow :h4אFV_D Sequential Workflow .1.2 KP, nD :! KF אs' Q ، N אصUML אلs' t אDiagrams א'אع אل53 'ع אولNא :ً 3א$+وא^אg,'عאN'אS و،hFאK3PאمKPTאs'37 3hFD 503 State Machine Workflow .1.3 :h אqوאh1א53D'F Q5DEא$g3^אg 504 WWF ﺗﻄﺒﻴﻖ .2 Hא\وF'نU،Hא\وFلIمאد$+\א53G1 'م7N،a1KF'مאن7N .AICi3Hא\وFلIد9א[وiدDא9وGH'م ض7f'RRb g( ، $Q F : وSequential Workflow Console Application $Q$% وعT3 z$ . אW :Qא$אKPTFV\א,, : codeActivity1_ExecuteCodeE$LאUא3א0MN وCode Activity אجH'مد7N אن C# private void codeActivity1_ExecuteCode(object sender, EventArgs e) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("***** First WPF Example *****\n\n"); Console.ForegroundColor = ConsoleColor.White; } ﻛﻮد 505 ﻛﻮد VB Private Sub codeActivity1_ExecuteCode(ByVal sender As Object, ByVal e As EventArgs) Console.ForegroundColor = ConsoleColor.Yellow Console.WriteLine("***** First WPF Example *****" & Chr(10) & "" & Chr(10) & "") Console.ForegroundColor = ConsoleColor.White End Sub While GR.אW،RRbHو3FلI د9אgN3אوجQ9QHאP7!sאSאi'1א :nDzN3א:N3ج+W אCondition אل$Q$R'م7Nو،Loop وC o.' false $ وLoop K 03 gjD$ אQ r Boolean 71N3 F7 'دfunction دא .HאF true .bIBQ5D אdeclarative rule condition nD zN אو$F!אلpאiدD9אFאU True N$t وאAskAgain دאfNאWSN^3U .RRVאאFP'لb'אU false N Hא\وFPbIoQ$−אKPT Condition طTאUא$ אאGאא,Tא53אW - :9 ً אو :א$و'د א C# public string Password { get; set; } private void AskAgain(object sender, ConditionalEventArgs e) { Console.Write("Enter Password: "); Password = Console.ReadLine(); if (Password == "Ahmed Gamal") ﻛﻮد 506 e.Result = false; else e.Result = true; } VB Public Property Password() As String Get End Get Set End Set End Property Private Sub AskAgain(ByVal sender As Object, ByVal e As ConditionalEventArgs) Console.Write("Enter Password: ") Password = Console.ReadLine() If Password = "Ahmed Gamal" Then e.Result = False Else e.Result = True End If End Sub ﻛﻮد This FDg!،RRbHو3FلI אدQ_'F! Activity !sאSi IאN'1Iאن :g!'دPאאWS0s وActivity GR .אW،Password is Wrong C# private void codeActivity2_ExecuteCode(object sender, EventArgs e) { Console.WriteLine("This Password is Wrong..."); } ﻛﻮد ﻛﻮد VB Private Sub codeActivity2_ExecuteCode(ByVal sender As Object, ByVal e As EventArgs) Console.WriteLine("This Password is Wrong...") End Sub :אKPT Sequential WF KK3PאKPT'نאPאWPS 507 :2jN א,,و a'لI (مدUلL' אSFًא$%$73'لI(مدnD:715P> WF אאلWSK^3אنª9*** KgUً^ א$OQ3'SوRsوא3אiH'Vא5P،FgN3KP'دP אhQ')f Iא03KPk@אO، . Debug وאلtrace אلhF!s'دאPאhQ') g!وizא. WF Code Liabrary .3 a7!@ وWindows Forms 03وC ASP.net 03KFא:NP> WF zTאNP3bאD'NאlWSU .I1אUg3א$+א53 و.dll o3gQ' ،Console 508 509 اﻟﺒﺎب WCF 20 510 511 h71g%'3i$Q$%N7g¦ذXPא013U .net_DUi$Q$אhN7Ns لאאI53 ًאz$i$Q$אhN7אل$אgCًNFsوذ،:! IوDא\'زh71وאChPTאnDKFtא .Sockets~zgوאWinsock53 .Qא$אWN3Web Services_DnDQi(NWCF_z$אK.و Web Service .1 K nD وC .net 23 א5D iHD S Web Service אgD 1Q 3 وC GQ وh3$I ً j$3 Interface אمو$+9אg%وאSg%'אNS'دV7\)אg% وאk@gNP وASP.net g!$Q$Rא G`Q Request GوC3CQ،Y3 Interface 1'אk'لb''نא3$+\ א01Q( و 23א4אYQ 3gFgOوCgFgOQ نC53ptوאXML ¿ Q3nDًدאFD אhttp protocol Q5Dk .3Zא0.'א3وig%وא 235DiHDGQو3$+!، AIC7Q1'عs'\אgOولאنRNو3$7\אوאoQאnNNوאن ، h3'\ אlWg 3$ א:D د53 و:N3 h3'\ אG و:دאN} م$+\'م א7Q g%ون وא$ N3NQ$3U@71אgN3G1،@71bאGQوh3$I SWh71אg,C53$ووא nD i'د%'3 'نP gC !sאم א$+ אg% وאk 'نPQ نC ذK و، ً ^3 iHאL א%H$ 'د .Zא 53א0BU23א4א0BنCcQ3 ،hאK^FHF XML nD$FGQوh3$+!NOCFو .4אqوCKqT(مא5D (NאqgFg!وg3K3אnDiHد. 'عNאאWSD$QنC$9ZאnDgOMW!¦نא !א، ً 7NOCF23אh3$نאC}و 23KFR F.C53$]!V+Tא¤زg%nDbא3$IX{نChدHC وذא،4א53 .^C وWindows 2000 !'وPQ353zא$א53IIS 512 .net ﺧﺎﺻﺔ ﺑﻚ ﻣﻦ ﺧﻼلWeb Service ﻋﻤﻞ .1.1 %H )دi$ و53 iHאL א%H دgj1D 'م7 Web Service KF 'م7 f' 0Qس אH$א אWS U :S3وא\دא،(Q'J3%H)دi$وgQ'R'م7(Qgg! result=(input-32) * 5/9 U k ً אZI وא، ASP.net Web Service ZI وאNew Project $Q$% وعT3 HI . z$و :ً ^3،V+T אnDg{QPlocalhost http://localhost/ConvertWebService $` F ، ASP.net U F ً 3e Web Config o3 gN3 hO\ אzT 'Q'م !`'אل 'د7 . Service1.asmx ]TNf'!jאhROVא3CGlobal.asax 9 אW ، אصWebService'ل אلb' אg Q t א7Q1 אS Service1 9'ن אP ً 79 ..ً ^3 ConvertWS5PوGN3אS qnN Web نC @N 9 5P ، 7 א\د א1 . .net אم$+ 1 C 4 'م7 F ً 3e وאن .ً ^3 TextBox j3hدوאCnD'9C$9Service :ً ^3 VB.net אKPT!'دs.אWو C# ﻛﻮد <Webmethod(Description:="iHאLאh%HدKQ'F^ل3"> public decimal Convert(decimal degree) { result = (degree - 32) * 5 / 9; return result; } VB ﻛﻮد <Webmethod(Description:="iHאLאh%HدKQ'F^ل3"> Function Convert(ByVal degree As Decimal) As Decimal result=(degree-32) * 5/9 Return result End Function .¤زg%nDً'دא%'3 IIS 'نPQنC@N9و،3$אlWS1X`Nوאن 513 :א1אP. وInternet Explorer 5PوOV\אO. http://localhost/ConvertWebService/ConvertSW.asmx .RRbiH'VKFg'53$]وאbא3$אن{א01 زg%nD3$`אa7!م$+7Q1אlWS و،KPTאאWg3$אمא$+אQ5!0.א'אUو .izOPKF gC53$]موא$+\א :`אK nDgN3W،GQ'א3$*jVא53د$D0sوU Webmethod אم$+אQ ،م$+FلH9אK. buffering KFDذאنF!د$bאlWSو: BufferResponse −1 . False وC True F.kو د$^وF.HF.WI] وCash KFD: I53QWא.'دא$Sو: CacheDuration −2 .$Q$% 53 hא لHא iدDא K. قq\א .'א .9مC Session bIKOذאF! د$:EnableSession−3 ﺧﺎﺻﺔ ﺑﻚ ﻓﻲ ﻣﺸﺮوﻋﺎﺗﻚ اﻟﻔﻌﻠﻴﺔWebService اﺳﺘﺨﺪام .1.2 Web Service م$+نC$Qو،LאhFً ^323UGQو3$I53iدO9 א$QNCضZON א: نW وאQ'J3 %H دQgg! 53 KQ'R 'م7Q Wس א وאH$ אU : NF. Wא .ConvertSW . Add Web RefernceZI אProject Fj.53 و،دDوز$NQو1zTאن. 3$+ و، س אH$ אU :4 NF. W אConvertSW.asmx HI . H 'א03 g( .3$אlWSgQ'tوאلא$*وאjVضאD! Viusal Studio 53!sא :'دP ً אQK7Nوאن C# LocalHost.ConvertSW conv = new LocalHost.ConvertSW(); ﻛﻮد 514 VB Dim conv As New LocalHost.ConvertSW() ﻛﻮد P (N אول وU iHאL א%Hل دI'م د7 C Label1 وTextbox1 0s' ً ^3 . وאن ، conv P´אوoQ אאص3אnD'dFאlWkK3P'دאPא،^אUض :א1!sא C# Label1.Text = Convert.toString(conv.Convert(textBox1.text)); ﻛﻮد VB Label1.Text = Convert.toString(conv.Convert(textBox1.text)) ﻛﻮد ﻣﻼﺣﻈﺔ g3$+Q Wא234אU.،3$אUKQ$KFF.'אذאSسH$אlWSzgאK. Iא:Nא Update Web HI א53 و5> א\وس אH gD aqM אQ 5D k Update Q$ KF .Reference اﺳﺘﺨﺪام ﺧﺪﻣﺎت اﻹﻧﺘﺮﻧﺖ اﻟﺠﺎﻫﺰة .1.3 R א$و،ZאnDi'د%'\ אWeb Service אلh3$I$Cم$+QوعT3KF'مאن7 f' : h3$مא$7QWאא0.'\אnDh^D رابط http://www.webservicex.net/WCF/ : SوgN3i$وאHIF.،3$I70 'אnD0.'\אאWS'd رابط http://www.webservicex.net/ValidateEmail.asmx م$7tאhT אUK>9אאWS5DRو9مCKPTאאWgK>א¤NSذאنF!3$אlWS 4§و . False אوTrue F7 و'د: IsValidEmail gدאאQ5Dوذ،وZPא$Q4אh3$I 515 'م7N53و،ً7:!sNF.WאH\وعTF$Q$% Web Refernce !s'م7،$DאFوאن *03 'م7f'Wو،'g3$אlWS03K3مא$+F5P>rمH'OאnD H ضD 53ط وT אF. HI אQ r 3C H ز53 و، وZP א$Q4ل אI אد:! Q .K>9אg!MessageBox :'S3אHزU:s وW'دאPא C# net.webservicex.www.ValidateEmail x = new WindowsApplication1.net.webservicex.www.ValidateEmail(); bool r = x.IsValidEmail(textBox1.Text); if (r) MessageBox.Show("RbK>;)" א ﻛﻮد else MessageBox.Show("±IK>;)" א VB Dim x As net.webservicex.www.ValidateEmail = New WindowsApplication1.net.webservicex.www.ValidateEmail() Dim r As Boolean = x.IsValidEmail(textBox1.Text) If r Then MessageBox.Show("RbK>)" א ﻛﻮد Else MessageBox.Show("±IK>)" א End If S و، אم$+9 אj, \ ( وiQ$% AIC 3$I h$% و0.'\א אWS U R אU HאF א03 :NS3$א${،:! IوN\@وא71אnDfbא رابط http://www.webservicex.net/globalweather.asmx اﻟﻤﺜﺎل اﻷول ﻻﺳﺘﺨﺪام ﻫﺬه اﻟﺨﺪﻣﺔ ﻫﻲ ﻣﻌﺮﻓﺔ اﻟﻤﺪن اﻟﻤﻮﺟﻮدة ﻓﻲ دوﻟﺔ ﻣﻌﻴﻨﺔ :ﻼ ﻫﺬا اﻟﻜﻮد ً ﻣﺜ، GetCitiesByCountry ﺑﺎﺳﺘﺨﺪام C# ﻛﻮد 516 net.webservicex.www1.GlobalWeather m = new WindowsApplication1.net.webservicex.www1.GlobalWeather(); MessageBox.Show(m.GetCitiesByCountry("Egypt")); VB MessageBox.Show(“Welcome”) Dim m As net.webservicex.www1.GlobalWeather = New WindowsApplication1.net.webservicex.www1.GlobalWeather() MessageBox.Show(m.GetCitiesByCountry("Egypt")) ﻛﻮد ن$\! א3 $Q tول א$ אX% وTextBox KFD אنX% ، V3 U A4Pن א$\ אzC N ضQ ...kA4Pא ﺑﺎﻟﺸﻜﻞ اﻟﺘﺎﻟﻲ، GetWeather اﻟﺪاﻟﺔ اﻷﺧﺮى ﻫﻲ ﻣﻌﺮﻓﺔ ﺣﺎﻟﺔ اﻟﻄﻘﺲ ﺑﺎﺳﺘﺨﺪام :ﻼ ً ﻣﺜ C# ﻛﻮد net.webservicex.www1.GlobalWeather m = new WindowsApplication1.net.webservicex.www1.GlobalWeather(); MessageBox.Show(m.GetWeather("Asyut", "Egypt")); VB Dim m As net.webservicex.www1.GlobalWeather = New WindowsApplication1.net.webservicex.www1.GlobalWeather() MessageBox.Show(m.GetWeather("Asyut", "Egypt")) ﻛﻮد ، \ אh Q'R 7\ אS N אnD i'د%'\ אh3$ אg,ن אC ,C نC 7 وאن nDدFD9א53ً9$h FאKQ'RUg3א$+אNP> rًQH'!h3$אlWS.E$ .HאF qtوאL אh9א\د N אg3$7Q 3$I אم$+ 234 אQ 5D 0!$ وא¤'N لV9 אK^3 ًא$7 ^C h3$I ً MQC ¤NS .:T3l{אU gNPQ' V.Sو.:! Iو ،@71אnDfא3$ISوiTN3 AIC3$I،:T3 l{אU S وRSS 3$I¤NSًMQC Tא53 ISPN h3'3nDf'אSوI'ع،:! IنوP وאFولوאوא$*אjVIو،N\א 517 h7 وאh Q'R א53 1 3 KP GQ وh3$I $` ً MQC ، 23א4 אU ¤$OQ $. .!א\و wcfﻣﻘﺪﻣﺔ إﻟﻰ .2 Windows Communication N7 .NET 3.0 H'g& وאt אi$Q$ אhN7 א53 i$وא لوאلV9§*_אt אAPI's وאل$א53D'FSو، WCF ًאHVIאk3Qt وאFoundation .:! I وremote access وאلweb services n y وx 5Qزg%nDY YG+אO'SNSKTאNq,'نPوgNDE$Rtא17Nא 23 وא$ 5D ig% 'لb' وאhPT אnD h71 אKF F אlWS N F r x=y U .LאZאVDetאh71א53 א... hO\אK7א[دو h! و، D'N אlWS 53 23 אQ'1 U 234F FD$ hg& t אhN7 א53 ^P א¤NS ، MSMQ ، DCOM K^3،:! IوhPTאhFb אAPI's אل03K3אKg'لL א53D'F ًMQא¤NS،hFאlWS K^}b אSystem.Runtime.Remoting JOאQ$7 .net N7H'g&03و ون،ًא$%i iH'VD'ز3(KFDhFD Kg53hN7אlWSNPe، XML Web Services N7 K730وאو4אhאHInDH'^وאiدQ*زV+אNPF! אمA'\אאWSUKFאUG9N Yً!g,9אS وNamed Pipes, Sockets, and P2P אم$+אQ5D$7 אU1iدQز 53 ^P '!אg א- 7 אhN7 אig, م$ א ( ًאNN وU K. אnD .net אلY3$+3 - .^لFسאH$א53z$אNP>،ً!.'א .N7אlWSnDf C$Nدم7سאH$אU، WCF _DK. .net 234FiLאlWS WCF اﻟﺒﺪاﻳﺔ ﻣﻊ .2.1 KPT WCF Service Library WCF وعT\'عאHI.، Visual Studio 2008KqT$ :ً ^3א 518 ¤NS،ًsאZ! אWWF N7وC RSS 3$I03g71 NP>r WCF g3$7AIChאHI¤NS .אنND's'3'SאWS@5P وWCF Service${$Q$% Web Site zTאhאHIא5FsًMQא :S assembly hO3E zTًsאZ!אF.$.O${אن WCF Service− WCF Service host− WCF client− :אE ^אh3'\'א!א53$9aو .:لV9אQW'אنאNدא$d'S:Address− .aقא:Binding− . WCF لI53SWONQtمאg\אob:Contract− Address ﺷﻜﻞ وﻣﺤﺘﻮﻳﺎت ال .2.2 :א3אqV א:،:KVW'אنאNאS WCF h3'353אو17Nא scheme://<MachineName>[:Port]/Path 519 i'د%'\אh9''و4אY3: I53KFf'Wو''لא4دא$ scheme نC Path ًאICو،: I 53لV9אWאWON\'אS Port :KVWنאP\دא$.MachineName .:لV9'دאWزאgאU Services אلH3'Sو :א\^لKnDאWS net.tcp://localhost:8080/MyWCFService :ﺗﺠﺮﺑﺔ ﺑﺴﻴﻄﺔ : IService1.csUא$oQ!s.SzTא$،i$Q$% WCF Liabrary zT . C# [OperationContract] int Add(int x, int y); ﻛﻮد VB <OperationContract()> _ Private Function Add(ByVal x As Integer, ByVal y As Integer) As Integer End Function ﻛﻮد :אא$אP. Service1.cs U53و C# public int Add(int x, int y) { return x + y; } ﻛﻮد VB Public Function Add(ByVal x As Integer, ByVal y As Integer) As Integer Return x + y End Function ﻛﻮد . YF.H $ ، ً ^3 אKPT WCF Test Client لI 53 g` . وRun KF . ، a7!و .KL `אInvoke nDaqM ؟Web Services سא'لH$א53 ^PKgCאWS@C 520 :YN7אYSY!'وPQ30.'353H7\אlWSK7]K،a7!אWS@ :אaאא4DgDא عNP>H7\א:%وC!'دאאضNذא رابط http://msdn.microsoft.com/en-us/library/bb310550.aspx 521 اﻟﺒﺎب ﻧﻘﺎط ﻣﺘﻘﺪﻣﺔ 21 522 523 0.א\'אQ'1_Dل7אK.وسH$ ل אIgs_t!אsطא7NאQ'NSض Debug - اﻟﺘﻨﻘﻴﺢ.1 WنאP\!א3nDًאHد.'نP9،CHGTz1ICi$DًCg(234אnDFDzNC i$j!hg&NS53،g.'NtאF7א5DO q3F.i]`!${CوC،ًא$Q$]1א:N3g& .KM!CiH'Vj1IC0Debugאل : BreakPoints Visual אل¤$Q وg 'لb' אH'! WON אo.'Q r 'دP א53 N3 53C nD gs وQ ط7 fNJאiدDאNP>،KT\א53S'I53$]وאgsوאאh אq\א..א3NP>،Studio .F5nDaqMQgNWONאb'א3وCF11nDaqM11WONא : ^3אKPT'دPאG%nDaqMوאC،د$[א1אUF9nDaqMBreakPoint!sאNP> FאنאG2N'نאPً3]دو%!אC9،hi$Dizא7'م7אN^3UAF،وאن ؟؟؟PT\אS3AQ،i 7و%'3'نPنC$9h I$\אKאن.'אنHXs 524 AIوאi'1אYK7Nא53و234אKqTz$F.و،.אF17NאlWSsאوWSK%א53 .F11 lWSUgh אq\אQ¯HNPFو،1אאWS'لb'א.وo.'i,3'م7234אنא$` :אKPTzNא ؟E$ذא3Ah'א1I6$،h'א1אUFאنא _ q\א،G'لRQ.אC$Q3$L.אKVQ3$NDً !،PT\אGK§UhC$אنאl .אWS534ًאF.HGD'Q$Q :X'1\א2NאnD'لVLאNP3CوFאgא...DoubleXMאFD2oQKLذنא 525 ًא$7'وb^C'عs'\'نאPi PאQHT3U، DebugאلFD53gN<tאi$jOאSlWS .hאدوאlWSnDدFD9K^3אKL'نאPאW،دوאلi$DYh אq\א..}ج\אHو iW!$`:אجh$%و3f$k،h אq\א. q5P>\אlWSUK،a7!אWS@ :ً ^3אKPT q :אKPT.א3i'د%'\אhJOوאh אq\אKًMQC :אKPTAdd WatchbI.א3!sאHIאNPF!:N q3.א3UH'و 526 :אKPTl$و:bI.א3iW!O'م7 ﺗﺠﻬﻴﺰ اﻟﺒﺮاﻣﺞ ﻟﻠﺘﻮزﻳﻊ .2 9 $. م$+\ز אg% و\ ن، م$+\ אg7N %r אن5 ، N א53 Ng א$. 'نP אن$ 'م7 Setup KP, nD 234 Publish KF 'م אن7 KF N 3 א زh'P\ ! אnD 'd .Build-PublishFj7א53ذQ،i,3:qTم$+\א .ً ^3C:\ahmed5P،:TN'دאWنאP\א$Q$R.Qא$− .CD-DVDH+N،:N3234א+KFY3$+F'دWنאP\א$Q$R.אi'1אU− .i'1אlWSKS{9وW7!Y3نP3Uh^Q$Rא5D234אRQنCUGNذא− .Finishaqsא− 527 ً ^3 ، Publish وعT\ אhאHI Q 5D h אq אKFD NP> ، lg{ z, K $` − .:! IوC!sאhO3YFM Program FilesU234אKFQf' وSetupnDaqM.،KFًאS%b אنא− . ًא$%دD234:3K3אNP>و ًMQC ، setup factory وinstallshild K^3 'عs'\ אlWS K%C 53 ً 3$7 ^C hدوאC אم$+ אNP> − Fj7א53'Q`'אل'دOאU SetupאلhDوT3S!'tא3$7\*אjVא53iدO9אNP> ::! Iوh.O9وאKFRאFDh,, وUPRאnDًאHد.'نPNew Project 528 C# vs Vb.net .3 :Tא:%وCوCقH'אOאSF!، Vb.net وC#tqnD'אز3KPTدFDאNوHدiZ!('אل9' ..net قאل19Qא$א17ً9وC$N.FgN hذאqe!'وPQ3\و،i$F\אqאS C# .netد¨אل3H'g&Qא$U :g,Q'אز3qQ'1g43§9C!'وPQ3hCH،!`'אلSو.'ذאU0'قوא +4 t وאVB.net hz% NS 53 ، .net د¨ אل3 1 gNP`'אل وO א03 Syntex אلU a7!PאX'א،>$7אqאYوgN$'א:T'אSאWSو، VBאلX']5P وC#אل53AIC .9@ Fg!h! I9'دאSNSKgא،lzOא015!VB.netوC#Y:Tא5DE$RאNאنوWو ...PאX'CUh.وOدאC$N،i$وאqQgNאU 529 1KIU؛0MنC@N9XH,2343':ً9وC* :h אq\אoQ7Q:ً* C# int x; ClassName x=new ClassName() ﻛﻮد VB Dim X as Integer Dim X as ClassName=new ClassName() ﻛﻮد 53ً9$iمא\وא$=!3 א$`F،==Gא#CU3C=GאVB.netUوطTאU:ً^* .<> :ً ^3S وhJOوאhאzא%9אUg3$+وEndK^3KBnDVB.netq$F:ًאH* VB if x=1 Then End if ﻛﻮد :'אس.אمא$+#CUS${FN C# if(x==1) { } ﻛﻮد :ًMQChאzא%9وאhJOאUWو C# using System Namespace MyNameSpace { class HelloWorld { static void Main(string[] args) { System.Console.WriteLine("Hello World") ﻛﻮد 530 } } } VB Imports System Namespace MyNameSpace Class HelloWorld 'Entry point which delegates to C-style main Private Function Public Overloads Shared Sub Main() Main(System.Environment.GetCommandLineArgs()) End Sub Overloads Shared Sub Main(args() As String) System.Console.WriteLine("Hello World") End Sub 'Main End Class 'HelloWorld End Namespace 'MyNameSpace ﻛﻮد .!||&&م$+f'#CUFNAnd,Or,Not,OrElseم$+f'net.!`'אلU،ً3I* .+م$+א#CU5PوVB.netU&م$+'صאVNא0B$ND:ً*د VB.netUElseIfS#CUelse if:ً* :ًMQC'אس.אnD#C$FQHאPאh7LאO!،End'عs'3UNOאF:ًN3* C# for (i = 2; i < = 10; i += 2) { System.Console.WriteLine(i); System.Console.WriteLine(i*10); } ﻛﻮد :'אس.א5DzNq9א5P>$وא1g'Uو C# for (i = 2; i < = 10; i += 2) System.Console.WriteLine(i); ﻛﻮد :ًא$'3ً P,WI]g!VB.netU3C 531 VB For c = 2 To 10 Step 2 System.Console.WriteLine(c) Next ﻛﻮد .:! Iوfor eachوWhileQHאPאh7Lא.N3@אOو .VB.netU()53ً9$[]'س7مא$+Q:! Iوh!'OVFN:ً* C# int[] nums = {1, 2, 3}; for (int i = 0; i < nums.Length; i++) Console.WriteLine(nums[i]); ﻛﻮد VB Dim nums() As Integer = {1, 2, 3} For i As Integer = 0 To nums.Length - 1 Console.WriteLine(nums(i)) Next ﻛﻮد nD XML CommentsWو، #CU/**/K^3 VB.netU153^ Commentً7${5* .3د7אiHא$b9אU3'D$3'نP$.gאhC.cC53א .F7א.nD'لVRVB.netUMod53ً9$٪Q'J\א3 مא$+f'#CU* #C@אلPDnDAssignmentUBitwise Operationsאم$+אVB.netD$5* .ذ h ذאh.!وSو،Q'qh.!وg'A$9h.وOאlWS !¦ن−3(9F −Kא5 وﻟﻜﻦ اﻵن ﻟﻨﺤﺎول اﺳﺘﻌﺮاض اﻟﻨﻘﺎط،سH$אQgU3gsaאHnD،i\F. . ﻏﻴﺮ ﺗﻠﻚ اﻟﻤﻬﺘﻤﺔ ﺑﺄﺳﻠﻮب اﻟﻜﺘﺎﺑﺔ 93'S وahmedgOS Ahmed !¦نVB.netU:C، case sensitiveSh.وOولאC* .GDمCi3אWSذאنF!د$CنC01C9و،BasicA'_אUqCU$%'Q :−HVI−VB.netUhא .#CU'د%'3@وVB.netU'د%'3optional parametersאلD*د .#CU'د%'3@وVB.netU'د%'3with* 532 z1IאiZOKM!Cً3(SوVB.netUi'د%'3Catch ... When* UGDgNPوi qVאh71אUi3lWSو، BackGroundU'دP CompileKF VB.net'م7Q* .'Q`'אل'دOאzaª i Pאh71א :−HVIא−#CUhא ًאz% @ :NP وVB.net U ً MQC :3א$+ אNP> 3 'S و، unsigned types fQ 3 #C D$Q * .qא53ًא 3 unmaneged codeوC unsafeאم$+vFאS VB.netU!'9t وא#CUA'.אi\*א image H'Vא3K^3h9 i$DUًوא.!OQ3،:! I وPointers nDKFאQ .:! Iوprocessing Low Level CodeA'\אO+N3'د03g353++C53Q. #CK%i\אlWSKو .5Q ^PK^3אHI9אXH,K®3'Sو :אKPT'د1MVB.netUdecrementوincrement${5* VB A=A+1 A-=1 ﻛﻮد :אKPTWم7אNP>#CUFN C# A++ A— ﻛﻮد .VB.netUS${5FN#CUsizeofbא${نCNP>* F. h ذאgC U g! (9 F و، ^ ًאg3 K3 t وאh! I9 אs ًא و%'3 אWS ن .i ﻣﺎذا أﺧﺘﺎر ؟: ﻓﻲ اﻟﻨﻬﺎﻳﺔ وذא#CX! C/C++/JavaXi4IQ$ذא3C VB.netX! VB 6.053ً 7N3Nذא .a7!V+,CC#,HCNونNQ3HIאU]!4لאUًא$Q$%N 533 :h.وOK3s'!'وPQ30.'353o\אאWS رابط http://support.microsoft.com/kb/308470 Monoﻣﻘﺪﻣﺔ إﻟﻰ .4 אو!ن% 'نn VM :DنP3 אnDKF.g®W وאVM nD$F!_אDU hאSC53لKnD:NPא!وWONUza'ع אs'\אאWSGQK7\אU،oQوPQ3 .!א nDA'KF . MFC وC C# وVisual Basic h`N3 Microsoft _DK7\ א_אUو .!'وPQ353KqT(א Mono 'SSg,C،iد$3KqT(nDKFא4FhدوאCمق و$7.'א035Pو .LאNH'ع دs'3'Sو 037!'א3gNPو، .net 2008037!'א3 Rb אMono ]ن$OQH$V3$%C_(Rאn0.א'אU aوאHi$Dh$%وذو،:! Iوh$D'א.وC71 23وאC ASP.net KP,nDz'א.net 2.0 nD 'لI$אNP>KnD،−g@−g7GC1k'b'$O! 'אLאh9وRF :HI9\אaאאאWS رابط http://www.mono-project.com/plans لGtאhN7אHI.KFRאKא3 لIو، Mono K Download KF .א0.'\א53 .g3KFMono $`،23א4אFj.Ul$` W وאMono אصلCommand Line אلKqTS^א\א :אhא\אدوאhאدوא5Fs53 534 XH,Q3' :mcs/gmcs `'אلOQ3' :Vbnc CILKQ3':ilasm/ilasm2 Visual Studio אل03 ً 7 K3 NF. F g3 K3 אQ - ^لF XH, א− gN3 i$ وאK i'د%'\אi$Q$אhN7אD$Q gmcs نC'S mcs وgmcsY$'قאHOא،ً7Command Line ..net 2.0_D03 X אصCommand Line אلO. ،ًא$%دD C# 'دnD'd sample.cs o3ضZON א3אGאMono : ﻛﻮد gmcs /target:library /out:Sample.dll Sample.cs !a7!و 4D gqT ً وMQ אexe ¤ build KFD NP> ، KqT א (مnD KF . P3 Q$ Rbאن א ...ً ^3@PNUmono :VISUAL STUDIOאلnDF MonoDevelop لFDوT3!NP>@PNאnD 535 .net ﺑﺮﻣﺠﺔ اﻷﺟﻬﺰة اﻟﻜﻔﻴﺔ ﻣﻦ ﺧﻼل .5 ig%אS3،Qא$אK.5Pو،'F[אig%'אSGQ'א''ج_אK.3$7\אNs'א3I ؟Pocket PCOPא KqT53gNP>QدوHS!sمא$73KqTאم(م$+F7N\אo'אkאig%C53D'FS Windows CE (مN!sنאFKqTو(مאWindows MobileKqTא3(KPTQو،(مNאאWSمg3 .OPאig%אnDKFtאKqT(אg,C:.3و2003 536 gN3 ً M 5P ، H'gT\ אnN\ Hard Disk Qد دHS e 9 OP אig%! QدوHk א$b nD 3C 'عC ¤NS و، زg אKqT iدD א$ :D 53 h א3 Q 9 Qد دHg RAM אل53 z% م$+Q .:,3وKqTو(مא23א4א5Q+ROMم$+AIC ؟net. لI53Pocket PCOPאig% :FDcNP>ذא3و نCzم'א$+Fh3$I7Rزgא53N3zא%Cم$+23!אsא4אq لI5301 * 3و ن אC ، h א$D'א. 5Q§ وSWON و23א4 א5Q+ (iאWאم א$+ )אa אم$+א .زgאU'Vאig%^ ًوא3 א3Pאمא$+ ؟C$Co .3CHزnDaqMא5DGHg(Q23KF'م7N،KP .Visual Studio .net'Q`'אل'دOאKqT.−1 .k I534'دאtאqوאCVBHI.−2 وC Smartphone 2003 وC Pocket PC 2003 HI . 53 و، Smart Device HI . −3 .:DKF'دאWزאgאGWindows CE 5.0 .Device ApplicationHI.GN\א7אHIא$−4 :IدאU'دPאאWSP.و،hאدوא53ButtonGR.−5 C# MessageBox.Show("Welcome..."); ﻛﻮد VB MessageBox.Show("Welcome...") ﻛﻮد HI.وC،:DKF'دאWزאgאG:!GWאdeploy'عאلHIאF5nDaqM.−6 .a7!`PC~אnDKFQ'ع 9،i,3:qTزوg אexeWONאo\אK7ًMQCNP>،אول23KFF.$7،¤و43−7 .Pocket PCOPزאgאnDً'دא%'3net framework.'نPQאنLאlWSU$ زgאN03K3V+\אSQ$7א4אUgDh'دtمא– אg\א−8 :,Tאg!G7NنC5P>tאig%אU,Tאl{א$Q$Rً ^F!،:! Iو 537 C# SystemSettings.ScreenOrientation = ScreenOrientation.Angle90; ﻛﻮد VB SystemSettings.ScreenOrientation = ScreenOrientation.Angle90 ﻛﻮد :Touch KeyboardYPFو C# InputPanel1.Enabled = True; ﻛﻮد VB InputPanel1.Enabled = True ﻛﻮد :coredll.dllא אد$زg`ResetKFً ^3و ﻛﻮد C# private int CTL_CODE(int DeviceType, int Func, int Method, int Access) { return (DeviceType << 16) | (Access << 14) | (Func << 2) | Method; } private int ResetPocketPC() { const int FILE_DEVICE_HAL = 257; const int METHOD_BUFFERED = 0; const int FILE_ANY_ACCESS = 0; int bytesReturned = 0; int IOCTL_HAL_REBOOT; IOCTL_HAL_REBOOT = CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS); return KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0, IntPtr.Zero, 0, bytesReturned); } VB Private Function CTL_CODE(ByVal DeviceType As Integer, ByVal Func As Integer, ByVal Method As Integer, ByVal Access As Integer) As Integer Return (DeviceType << 16) Or (Access << 14) Or (Func << 2) Or Method ﻛﻮد 538 End Function Private Function ResetPocketPC() As Integer Const FILE_DEVICE_HAL As Integer = &H101 Const METHOD_BUFFERED As Integer = 0 Const FILE_ANY_ACCESS As Integer = 0 Dim bytesReturned As Integer = 0 Dim IOCTL_HAL_REBOOT As Integer IOCTL_HAL_REBOOT = CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS) Return KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0, IntPtr.Zero, 0, bytesReturned) End Function ؟net. ﻛﻴﻒ اﻛﻤﻞ اﻟﺒﺮﻣﺠﺔ ﻣﻦ ﺧﻼل 1M F! ، Pocket PC nD KFQ 234 NPF\ א£V אaC 53 $Q 7 א23א4 !¦ن א$] KP VN אhO\אم א$+ אNP> h א$D'א. 03 K3 وאQ$ א23א4 אU 5Q+אم א$+9 .SQL Server CE'ع53hא$D'א.nوXMLhO3وC،h$D'א7 ::N3z$!'وPQ353aאאאWSnDi,3ًMQC'لI$אNP> رابط http://msdn2.microsoft.com/en-us/library/aa458721.aspx 539 اﻟﺒﺎب 22 اﻟﺒﺮﻣﺠﺔ ﺑﺎﺳﺘﺨﺪام ASP.net 540 ﻣﻘﺪﻣﺔ إﻟﻰ ﺗﻄﻮﻳﺮ اﻟﻤﻮاﻗﻊ .1 lWS لI و، Desktop Applications ~ وאConsole _ אلD U E$R N ، وسH$ א53 nM3 F! nD $FQ 0s' ن א$7! P, 'د% وU n و، WON $ز وאg% 'د% وnD $F N Kא\א ،NQCHF web serviceXلV9אوאHدV\אUHT\ אوא5QزgאYhل7لوאHאhFD Qא$ אK.אWو،ًo0s'!ً3'FD server side languages_אلD אوASP.net _אلD033א :Zא0.'א3א'אعnDfאنG h, !وH'bאم$+ א5P>،HTML אم$+hOb'א53D'F5DiHD0.א\'אlWS:0.'א3 .0.'\אאWSU\א'אعא53א'ع$%'Q95Pو:! Iو KFאG%UK(gNPא'אع א\و0FQ0.א\'א53'عNאאWS :KFא$NDP3NQد0.'3 KF33אSאtאROVא5P، VBScript وJava K^3 Scripts אم$+א0.א\'אlWSUQ،a7! .a7!א¤$ND אن5P>W א2NאnDa7!אKVא !وU:3KFDQ 'عNאאWS :P3NQ د0.'א3 .Zא0.'3 @وZא1nFQLאlWSU،^'عאولوאNא53'نPQ :ﻣﺜﺎل ! א3 אوאnD ' ^'ع אN א53 ROb S 33 אS אtو אZP9 א¤$Q ROb lWg ROV אlWS KPT !¦ن0. א'אU 5P ، HTML 53 :! I'لو7Lאول وא$! אs אQP tאولא$אP,وhא$D'א. izא73.tא !אhFDQ5Dz%qVא .:! IدوHא'א$Q4אnD' i$ST301NPو،g ! אetאqא'אدאQ¯HnD Hد. אROVאlWSUאW .a7!! אnD\אhFDאنa7!2jNא :دورة ﺣﻴﺎة ﺗﻄﺒﻴﻖ اﻹﻧﺘﺮﻧﺖ 'م7Q http - م و''ل$+ אcQ 3 'S وhttp:// - X C$Q 3 0.'3 'אنN I}`د אد אאلWS'م7Q، DNS ًאHVI وאDomain Name ServerXfQ3'אنNא אWSلHو''ل4א 541 KP,،0.'\ אGb IP صلIZאnD Physical 'אنNgPF.tאPאKQ'R DNS :^لFאKPT'نPQ DNS אل GلHאQ و− 80'نPQ3ً port - !Qאن،0.'\אאWkF\ אIP !3نP39bאنא .http Request:D13'Sو0.'\אאWS\א 3Q dynamic ROV'نאU3א،a7!'1\ אROVאدQ، static 0.'\'نאU . http Response :D13'Sمو$+\א2jNאRObلH' وא1\אhא ﻣﻼﺣﻈﺔ a7! http 'SNS NFgQ3و،KFDiHدوK'وKP : Client Side Web Sites ﻣﻮاﻗﻊ اﻟﻌﻤﻴﻞ DoV53K. لאIgDfאNP>ًא$%gq Sو، HTML X!3Qא$'عNאאWS مQ :ً ^3aאאאWSQ5D رابط www.html4arab.com دونא0.'\אKFDP3bא، Dream Waver Xzg وאFront Page Xzא$א23אH'g&03و .a7!hدوא9אQ5D HTML !ل3 W אForms _אلD${ HTML אل5FsًMQא،*jVא4 vbscript אوJava ًجلMQא سH$א%א3NP>،'عs'\אאWSU!\وجא،%Hא_א03 Kbא'א53NPF :−tو$353–vbscript~Qא$א 542 رابط http://ahmedgamal-technical.blogspot.com/2008/08/vbscript.html : javascript KQא$سאH$وא رابط http://www.w3schools.com/JS/default.asp ...ً אא¡لWSU ^PאN3GC9،a7!h93א0.'وאنא : Web Service وﺧﺪﻣﺔ اﻟﻮﻳﺐWeb Application اﻟﻔﺮق ﺑﻴﻦ ﺗﻄﺒﻴﻖ اﻟﻮﻳﺐ bIiiHدوktאhא$D'א.'אدو9אhO3 وhROVא53D'F5DiHD 'SGQ'א1 :! IوEא$אWONوg. وאgR! Q،23אK^3g^3 K3אQ،\אhFD$S$وh אK73$I5DiHDg!GQ'א3$I3 א .a7!hH'א.Hوg'لאb'אnDiHد. qא53g3 : IIS اﻟـ nDz 'אASP.net אل¤'دKFطא,l'د%وو، ASP.net وASP h4'א !אصS .ً 79.'3:DoMW א !אnDوCV+Tא¤زg% KFRF.]!.$ אوIIS אلKFRF.אcQ visual studio K setup KFF.' ً ^3 Notepad iPO\אnD4'دאNذא3א، IIS אلKFTQ W وאWebDev.WebServer.exe Add 23!وאزאאs אControl Panel - PR'אHIאQ5Dوذ،: setup KFD53$ ! 53$` ، Add Windows Compomnent وز$NQوh'P3!sאZI وאAnd Remove Programmes .−KqT(مאG7Q1 אq–IIS'אلS وInternet Inforamtion Services gNFs :ﺗﺠﺎرب ﺑﺴﻴﻄﺔ 543 :g! אhQ'[אP.ً ^3 index.html 'نPgF.،$Q$% Notepad O . ﻛﻮد <html> <head> <title>My First Pgae</title> </head> <body> <center><img src="http://l.yimg.com/a/i/ww/beta/y3.gif"></centeR> <br> <font color=red size=3>Yahoo!</font> <br> <a href="http://www.yahoo.com">Link Here</a> </body> </html> .ZאRObאولlWS،¤و43،gDא\دوجaqMi,3gqTX% :hلאIد9مאH'O'مא7Nאن :مH'OאאWg'دאصPא ﻛﻮد <html><head> <title>My First Pgae</title> </head> <body> <h2>Welcome !!</h2> <br> <form name="form1"> <table border=0> <tr> <td> 544 Name </td> <td> <input type=text name=textname size=10> </td></tr> <tr> <td> Password </td> <td> <input type=password name=textpass size=10> </td></tr> </table> <br> <input name="button1" type=button value="do anything"();"> <input type=reset value="Clear"> </form> </body></html> Sg(f'!hلIمد.' ،مH'OאUhلIمد.م$+\نאC53$]'م7אن$Qوאن :אKPTVl q وButton1 H GSWNאW،ًMQא,TאnDوVHU: ﻛﻮد <input name="button1" type=button value="do anything" onClick="doCheck();"> : אScript אلP'م7f'ROVאIU53و ﻛﻮد <script language="javascript"> function doCheck() { if(form1.textname.value!="" || form1.textpass.value!="") { alert(form1.textname.value); document.write(form1.textpass.value); } else alert("enter data first !"); } </script> 545 : Visual Studio اﺳﺘﺨﺪام `'אلO אO . ، Visual Studio لI 53 ASP.net אم$+ 5P و1 א` אlWS @O K7NN : ASP.net Web Site ZI אWebsite $Q$%GQوHI.'وQ'د : אhدوא9א535PموH'O@אO.אن 546 ﻣﻼﺣﻈﺔ ال تنس اننا حتى اللحظة نتعامل مع ادوات HTMLوليست ادوات ASP.net و'73$NDم'0sא'PدaqM.،א\دوج Button nDوP.אوא:i,3 3 547 :ROVאKOאGQ'אQ5DFgN3i$ وאKאوQ''دPوאFVאאضאNP> . ASP.net 03K3C$Nدم7سאH$ אU،1אN{SlWS...a7! ASP.net ﻣﻘﺪﻣﺔ إﻟﻰ .2 X`NسH$אאWSU،:DO GQوhRObKFD وVisual Studio 03K3אN%אNHدU .DOא0.א\'א03אوN{ : ASP.net ﺗﺠﺮﺑﺔ H زU ، Button 3CH وزLabel 'אنND i وאدאTextBox * 03 . ، Standerd h אدوאO . :'دאPאP.3א C# Label1.Text= TextBox1.Text; ﻛﻮد 548 VB Label1.Text= TextBox1.Text ﻛﻮد . ASP.net RObאولKFF.$70.א'אU...X%و ﻣﺎذا ﺣﺪث ﻓﻌﻠﻴ ًﺎ ؟ 'S3!¦ن0.א'אU،مH'!nD'dدD HTML 'دQ$ نC$` HTML אلRObR!' 3 e! אnD¤NSو،! א3مH'OאhلHم.! אSubmit Eو$ 03A')ًنQ אو אAhmed A'[אnD'd Label nD'tאROVאiدDوאhא :'دPא53אzא$`{N אROV אصHTML 'دPאi$ST3%'،لH9אK.*Nא ﻛﻮد <p> <span id="Label1">Ahmed</span> </p> <p> <input name="TextBox1" type="text" value="Ahmed" id="TextBox1" /> </p> <p> <input type="submit" name="Button1" value="Button" id="Button1" /> </p> .a7!! אUg!:! I'אدو9 א3א، Label12NאiدDوא،hא3e،ذF .اﻧﻮاع ارﺳﺎل اﻟﺒﻴﺎﻧﺎت Q sאZ!9 אS אو و7Q1 אU ، GET وPOST S hل אH9 Y7Q ¤NS Form C U N مאصH'OאKQ$X%،OV\'אنאNDUkH !אGETU3א،i,3 Form אلhلHא :אKPTV ﻛﻮد <form id="form1" runat="server" method="get"> :אiH'Vאª9،AICi30.'\`א. 549 3CمH'O'لאnDًودא$0MhROV\(א3ً،'אنNאU مH'OאhQ')!لHאQ،AF .'د.א¤NS! POST U z,ن3د.hא3U:Df$.3'Sو،'دPVON3gzא.hدH 'אF!izא.7QgN3i$وאKP . א : Code Behind U،FVא5D'دP אKV!S>$7 אASP 5D ASP.net 03hg&tאi$Q$אhאF\א5Fs53 :ً ^3'دPא אWSAN>$. ASP Classic ROb ﻛﻮد <% v_Id = request.querystring("id") response.write "<form action=test7.asp?id=" & v_id & " method=post>" response.write("<font color=red><b><center>Write your C.V.</center></b></font><br>") %> <table> <tr><td>Computer Skills :</td><td> <input type=text name=v_cs size=30></td></tr> <tr><td>Characteristics :</td><td> <input type=text name=v_char size=30></td></tr> <tr><td>Interest's :</td><td> 550 <input type=text name= v_inter size=30></td></tr> <tr><td>Language Skills :</td><td> <input type=text name=v_ls size=30></td></tr> <tr><td>Education :</td><td> <textarea name=v_edu cols =30 rows=6>write your Study Field here</textarea></td</tr> <tr><td>Experince :</td><td> <textarea name=v_exp cols =30 rows=6>write your Experiences here</textarea></td</tr> </table><br> <hr width=75%> <center> <font color=red><b><center>Join Demand</center></b></font><br> <textarea name=v_Join cols=40 rows=9 WRAP=physical></textarea><br><br> <input type=submit value= Continue> <input type=reset value=Erase> </center> </form> אد$3لN3o3 U FVאbאYU *.cs אد$3o3U¤'אدCRb! ASP.net U3C :*.aspx ًMQوא،^ ونPאgMOQزאل37QSنאذو$ وאo3UgدnDًאHد.ز3وذ .T\א0QHT\אUًb'VI ASP א'אدאلaspx אلo31ن9 אUج$. X'אK(Q ذ5Pو،234\אnD39אKgوKIא$KFDم$Fbً !،'دPאzOI'صאVx :ط7i$Gאi$وאRObUPא U KFQ W* وא.cs - ROb لI 53 gD KF א01 9 t'אد א9 א0s' ج3 ً C - .ذ¤H$Qאن01Q وعT3 .Y4\אYK7Nوא0Qא'زUKgאVisual אنH−a7! $وאo3UKQ$אG1QK7אKQ$!،KQ$אUKgא.'@אOUو . { 5DFIوg.'אDאن9,\אKQ$אi3م$7QStudio 551 NH'ع دs'3'S א وgM nD i$F3 hO3'د%م و$ Deploy אلFD U Kg אS W و.א : ASP.net ﻣﻜﻮﻧﺎت ﻣﺸﺮوع ال hO\ !s' אd : א$` ، OV\ אY> nD 'د%'\ אWebsite Directory אلOV F. ' :− gP7אz9אlWg!i'د%'35P_'n− אhא$¡אnDDوT3 .:P3אnDzNOV3K03K3وOV\*'عאN7tאhO\ אnD'd:App_Browsers .GQ'אhROb*§t אClasses hJO'אدوא9אhO3nD'd:App_Code .hא$D'א.hO3nD'd:App_Data . *.resx HدV\אhO3nD ':App_GlobalResources .وعT\bאh Q وאg(\ctאhO\אnD'd:App_Themes g3$+Q Web Service אل53 אو א 'عProxy 'د و% وU : App_WebReferences .NSgsوQ71 .Ug3א$+אQt* وא.dll אلhO3K^3iSאhO\ אnD'd:Bin : دورة اﻟﺘﺮﺟﻤﺔCompilation Cycle 53 7T3 ClassJ! :Q') K3P o\ אB Q ، Single File o\ 'ن אU _aspx .!لsאROV@אOSystem.Web.UI.Page 552 23$5Pوh'א1@אOKFD!، Code Behind KF אصMode K3א$+ אU3C ،: Compile KFDQ InitializeComponent() אلnD'dWאnF\אo\א،Q'hO3E .i,3 System.Web.UI.Page53@و:N3 CS + ASPX 53'نP\אo\قא7,ًא79 …'7N3H'V***א System.Web.UI.Page اﻟﻔﺌﺔ .3 :gN3،FDU¤$OtאhJO*وאjVא53D'F nDJOאlWS' ob'א JOא 0.'\*3و1אh אq303K3א Application 0.'\אאWgشאصPא03K3 Cache zNk Load KFDQ:مאC$Q$%53k Load KFDQROVאKS!\ IsPostBack ROVא53$ Submit FDnD 553 ً 79gDfN،Z\אROVא$Q$ MasterPageFile سאH$אUgDfN، Http Rquest אل Request سאH$אUgDfN ، Http Response אل Response HttpServerUtility5Fs! א03K3bوאلא$'لאb'א Server ً 79gDfNو7א5Q+ م$+، Session אل03K3א Session ROVאlWgאص−: BfDא9−^א$Q$R Theme Request اﻟﺘﻌﺎﻣﻞ ﻣﻊ .3.1 gD01QhلאHאFD،gD3Fg3WON! אhلHאFDS Request אلFD . Request א . Request Fg}'م7QHאאWS(لH)אHزnDaqM 'م7V+TאhلאIאد$:^ل3 لH9אX'א$Q$QF، ghلאHאQtאROVאS وAction אلoQQ،iאدU :ً ^3אKPTمH'O אoQUًوذ7SN,t אPost وCGet ﻛﻮد <form name="form1" id="form1" action="Process.asp" method = "GET"> ... </form> :ً .O7Q1مH'OאoQQ5Pو،ًMQ(مאN@אO .net U ﻛﻮد <form id="form1" runat="server"> . POST SsאZ!9لאH9 א7QאنFROV@אOSg!'دtאROVًאنאsאZ!אcQאWS 5Fs b אlWS RNe gNP و، Http Rquest i,3 'لb' א9 ASP.net אن :*אjVوאلوא$אg!${tوאSystem.Web.UI.Page.Request 554 ob'א bא−א$א ! אnD 0.'\אH3 ApplicationPath h3'\א53 د$DnD'J!Sو،م$+\אOV3 'ع Browser م$+\אK.53kHאt'אP אhO3!3 Cookies Get אوSet لH9אD' HttpMethod PostلH9 'نאU! :HאWمאH'OאhQ') Form ، Get لH9 'ن אU ! :H אWم אH'O אhQ') QueryString hQ') 5Fs 53 5P _ ' n i,3 URL אلhQ') izא7 'م7Q مH'Oא 9אم53 Http لVא1QKS !\ IsSecureConnection h!sونאא$ URL !אل3 RawUrl ! אh אq3D'F03K3'لوאb'א ServerVariables KF אIP !3 UserHostAddress KFoM\!אא3 UserHostName ! אnD77H3X'1\אH\אKQ'R'م7دא MapPath() ! אnDo3nD http אلhQ') ªO SaveAs() ... Request אم$+א5D^39ض אNو : Form ﻗﺮاءة ﺑﻴﺎﻧﺎت اﻟﺘﻲ ﺗﻢ ارﺳﺎﻟﻬﺎ ﻓﻲ : Post X'مא$+N' C# firstName = Request.Form("txtFirstName"); ﻛﻮد VB firstName = Request.Form("txtFirstName") ﻛﻮد : GET X'مא$+N'و C# ﻛﻮد 555 firstName = Request.QueryString ["txtFirstName"]; VB firstName = Request.QueryString ("txtFirstName") ﻛﻮد 7Q1אlWkجRא9 ،وسH$ولאCUN,F ID אمאل$+i,3gzא.01وא .!sאAIChFDU :ﻣﻌﺮﻓﺔ اﺣﺼﺎﺋﻴﺎت اﻟﻤﺘﺼﻔﺢ اﻟﻤﺮﺳﻞ ﻛﻮد C# string theInfo = ""; string isAOL = string.Format("Is AOL? {0} <br/>",Request.Browser.AOL); string isActivex = string.Format("Support ActiveX? {0} <br/>",Request.Browser.ActiveXControls); string isBeta= string.Format("Is Beta? {0} <br/>",Request.Browser.Beta); string isJava = string.Format("Support Java Applets? {0} </br>",Request.Browser.JavaApplets); string isCookies = string.Format("Support Cookies? {0} <br/>",Request.Browser.Cookies); string isVB = string.Format("Support VBScript? {0} <br/>",Request.Browser.VBScript); ﻛﻮد VB Dim theInfo As String = "" Dim isAOL As String = String.Format("Is AOL? {0} <br/>", Request.Browser.AOL) Dim isActivex As String = String.Format("Support ActiveX? {0} <br/>", Request.Browser.ActiveXControls) Dim isBeta As String = String.Format("Is Beta? {0} <br/>", Request.Browser.Beta) Dim isJava As String = String.Format("Support Java Applets? {0} </br>", Request.Browser.JavaApplets) Dim isCookies As String = String.Format("Support Cookies? {0} <br/>", Request.Browser.Cookies) Dim isVB As String = String.Format("Support VBScript? {0} <br/>", Request.Browser.VBScript) 556 Response اﻟﺘﻌﺎﻣﻞ ﻣﻊ .3.2 ، AIC i3 KF א ! א53 h אK7 FD K^e ، Request F P אFא :وאلא$*وאjVאnD'و،م$+F:H אWא2NאKPT ob'א א$وאCbא 2NאUم$+\א3Z(مא ContentEncoding PאFאU5P وRequest אلUF CacheوCookies (Rאnم$+\لאVאQHאFא53$] IsClientConnected Headers وאلBody אلhQ')!3 Clear() a7!lzgא3لHא\وאhFDzgא End() **ًא$%i$O3**\אFDf7QدونאKFlא<ز3لHא Flush() $Q$% URL KFאKQ' Redirect() ROVאnD Write() : Write אم$+PאnD ^ل3 C# Response.Write("<u>This is javascript code</u>"); Response.Write("<script>alert('hiiiii');</script>"); ﻛﻮد VB Response.Write("<u>This is javascript code</u>") Response.Write("<script>alert('hiiiii');</script>") ﻛﻮد 557 ASP.net أدوات .4 F!و، *.aspx UX'P3 HTML لI53Q ASP.net hدوאC 53iאدאCoQ!¦ن،7N(9F g א9 ، 234F g3 3 وg(\ א53 N71 U Q אدh دوא:T אi$Q$, g! א ذ$D .1.KPT'دPאzאHو3وzאدאUo§ K7 Q Event א03 و، GQ'_ אD 03 GN k aqs KFD t ً وאMQ אEא$ N 3א אWو .i,3! אhא : AutoPostBack ﺧﺎﺻﻴﺔ Text *Nאh3UbאlWS${،g!Q$א03 i,3! אK7NאbאlWS Combo وList Box gD'אj'א7 وאCheck Box & Radio Buttons $Q$R وאHI9אh وאدوאBox . false SksאZ!9אF7 وא،Box اﻟﺨﺼﺎﺋﺺ اﻷﺳﺎﺳﻴﺔ ﻷدوات اﻟﻮﻳﺐ .4.1 :وאل א$*وאjVאk$<t وאSystem.Web.UI.Control JOא53GQ'אhدوאC0B T ob'א א$وאCbא iאدאlWkzNאh אدوא0B$ Controls iאدאlWSKIدאhدوאC'د%م و$DوC'د%'71N3F.$ HasControls() -lHאP5P>9−iאدאKP$'\א9א ID iدא9אlWS'tאROVאnD q}'د Page iאدאlWkNsL אiאدא Parent iدא9אlWSzOIאوאH'g& Visible *jV אgN3 7T\ אhدوא System.Web.UI.WebControls.WebControl JOم א$7 F :gN3،وאضg(\ 7\א 558 ob'א bא O'نא BackColor ود$L'نא BorderColor ود$LאKQ BorderStyle ود$LضאD BorderWidth iאدאKOم$DوCKO Enabled iאدאlWk styles אصلclass אل CssClass iدא9אlWk:! Iو9`وאLא53 aאh3'3 Font PאaI'ن ForeColor 'ل1א Height אض Width Tabאم$+K7Nא53g.'3 TabIndex i دאTips 'د%وU ToolTip : اﺳﺘﻌﺮاض اﺳﻤﺎء ﺟﻤﻴﻊ اﻷدوات ﻓﻲ اﻟﻔﻮرم: ﻣﺜﺎل hدوאC 'د% \! وHasControls()א$ !sאControls b א5D 2N אCollection אم אل$+ 'دאP אNP>،:3$D53 C# string Information=""; if(myPanel.HasControls()) { foreach (Control c in PanelName.Controls) { if (!object.ReferenceEquals(c.GetType(),typeof(System.Web.UI.LiteralControl))) { Information+= string.Format("Control Name: {0} <br/>", c.ToString()); Information+= string.Format("ID: {0} <br/>", c.ID); Information+= string.Format("Control Visible: {0} <br/>", c.Visible); Information+= string.Format("ViewState: {0} <br/>", c.EnableViewState); Information+= "<br/><hr/><br/>"; Response.Wite(Information); } } } ﻛﻮد 559 VB Dim Information As String = "" If myPanel.HasControls() Then ﻛﻮد For Each c As Control In PanelName.Controls If Not Object.ReferenceEquals(c.[GetType](), GetType(System.Web.UI.LiteralControl)) Then Information += String.Format("Control Name: {0} <br/>", c.ToString()) Information += String.Format("ID: {0} <br/>", c.ID) Information += String.Format("Control Visible: {0} <br/>", c.Visible) Information += String.Format("ViewState: {0} <br/>", c.EnableViewState) Information += "<br/><hr/><br/>" Response.Wite(Information) End If Next End If : اﻧﺸﺎء أدوات وﻗﺖ اﻟﺘﺼﻤﻴﻢ: ﻣﺜﺎل C# TextBox t1 = new TextBox(); t1.ID = string.Format("dynamict1"); myPanel.Controls.Add(t1); ﻛﻮد VB Dim t1 As New TextBox() t1.ID = String.Format("dynamict1") myPanel.Controls.Add(t1) ﻛﻮد : ASP.net أﻗﺴﺎم اﻷدوات ﻓﻲ :jH'אعCi$ ASP.net Ui'د%'\אhאدوא7N : Simple controls Label 'אنN وאTextBox *N אh3K^3ً אHTML bND53gNP وASP.net 0tאhאدوא .:! I وButtons 3אHאHزCو 560 : Rich controls i وאدאCalendar Q'7 אi אدאg^3 א53، *jVIًوT^ אgNP وQ אدASP.net hدوאC 53 D'F :! I وMenu j'א7 وאTreeView i`TضאD : Data controls GridView g^3אg,א53،hאi$D7aאnD$FhאدوאS : Validation controls g! JavaScript hQ')1 Q،KFא$NDSWONQ5P !وhאدوאS،7Rאhאدوא .7RאhFDWON : Login Controls .:! I'لوI$אK` 3P\אhدوא9א53D'F : Web part controls .ROVאzא%* אjVI'نوUPR.'3م$+\bOא9VVhאدوאD'F .7gND N$t وאHTML Controls 01¤NS אאل$D3אوiFNDFtאbאhאدوאlWS nDfא3د7وسאH$א5FsولRN .hא$D'א. + ASP.net אل.ngNDQ$L אK%pNtوאGridView MasterPages .5 z`و$Q،hROVאKU l qQ90.'\א53ًًאz%אن0.א\'א53 د$DUª .hROV אKUًאHP3و$Q:NPوg3KDOQوROVא53 z@אOKFF.وROb 100:0.'\אنאK+،hROVאKUً'دא%'3@zאאWS0.א'אU .3 ROb 100 אلU KQ$ 1M! ، :VjVI $ אq U H ، i3 K U 53 z% אU gN ROV Include KFD Q نW وאASP U include אلC$3g& NS 53 hROVאKPjHROb3ROb53K{t وאMaster PagesאلNhg& ASP.net 03و،ROb :אKPT Master Page ZI وאNew Item !s.،Q'C$\אאWSX`N 561 :א$Q$אVN'دא%'وS'دP אRObU:( 3אول،k¤zTא$ ﻛﻮد <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> lWS$وK.O+\ א¤א'אد0s'.،k Master Page KFDtאROVאY'א5QWSK^> .g!jאROVضאD!71N\אlWS3א،71N\א א\^لU،a7!ROV!'قوאK(gאcQ 9''د!'قوאPنאCא،a7!אWS@ nD'AI9אh3 9אلF!ROVאaوa7! qb03U g(jאROVאK`Nא :ً ^3אiH'V ،3h 562 : אKPT'نPROVאlWg'دאصPא ﻛﻮد <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> <asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder> </head> <body> <form id="form1" runat="server"> <div> <center> <table border="1" width=80%> <tr> <td>hiiii, i am here</td> <td><img src="http://vb4arab.com/vb/attachments/logo.jpg" /></td> <td>any thing</td> </tr> <tr> <td>hii again</td> <td> <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </td> <td><input type="button" /></td> </tr> <tr> <td colspan=2>large TD :)</td> <td>bye</td> </tr> </table> </center> </div> </form> </body> </html> 563 RObzT.FVא53 zg9א$،a7!'دPא53@ وDesigner لאلI53gFFV5P>ًو : אKPT:S$Q$R. Master Page G,,Uو،i$Q$% 'م7KPT@אOnDk'VUGRObא03 وאن،AIא,,US$Q$N3G1ً79 Page :UאbאKQ$NP>>$.ROb 'n،F7@אOSz1D : ًא$Q$'אאWS'د%وiDא3و ﻛﻮد <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> </asp:Content> . html ووhead אلK^3hאHאPnD'9@אنN95P Sitemap اﻟﺘﻌﺎﻣﻞ ﻣﻊ .6 KPTً7901،gو.'3hQ')oQ t وאSiteMap אل5j033 لI53 :אKPT sitemap !sً9אوz$N،.'3 hROV`,ضDوj'א. 564 :ً sאZ!'دאאPא$` ﻛﻮد <?xml version="1.0" encoding="utf-8" ?> <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > <siteMapNode url="" title="" description=""> <siteMapNode url="" title="" description="" /> <siteMapNode url="" title="" description="" /> </siteMapNode> </siteMap> :YO YRObgوQא$אRObً ^3ضZON، Nodes אلlWSoQNFg3אن ﻛﻮد <?xml version="1.0" encoding="utf-8" ?> <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > <siteMapNode url="Default1.aspx" title="Qא$אROb" description=""> <siteMapNode url="Default2.aspx" title="'وS'א%'ROb !" description="" /> <siteMapNode url="Default3.aspx" title="A$N\'א%'ROb" description="" /> </siteMapNode> </siteMap> 565 Menu !s'م7NوN b אMasterPage אلK7NN،h3'\אlWS53iدO9ولאRNאن : sitemapאאلWS'نPk DataSource אل$Q$و Site map ZIא، DataSource 'عאل$Q$N3G1אi'1אU : אKPT'نPWوא.'3KqTX%،אن : SiteMapPath :ً ^3אKPTنP\ א$Q$gFg3،D'F¡@אO0AIאiدאC 566 iH'VROb K303KFو، masterpage אلUgs'. أدوات اﻟﺘﺤﻘﻖ .7 hאدوאnD 'و، Client SideKFאg%gאKFQh I$\א537Rאhאدوא53D'F S :א F $] iدD אU ً ^3 $O ، AIC h I$} g% U h I$\ אH7\ :CompareValidator − 7RאאWS1UiאدאlWS aH،Hא\و l$Q$QY3ق15Fs07 h I$\אنא53$]:RangeValidator− .hلIمد. م$+\نאC53$]:RequiredFieldValidator− ¤$O Regular ExpressionnDzN 7Rא53'ع$Q$NP>: RegularExpressionValidator− Regular אل5D $Q\ \! א، oS .H و אوZP א$Q وC 0.'3 Rb 53 7R אU ً ^3 :−D− سH$א אWS%א3NP>Expressions رابط http://www.arabteam2000-forum.com/index.php?showtopic=77787 ::G RegularExpression אجא+9Y.'\א5QWS53iدO9אNP>ًMQC رابط http://regexlib.com/DisplayPatterns.aspx http://www.regular-expressions.info/ .bא7Rאhאzא%אzN :CustomValidator− .مH'Oא אWS U e t א7R אhFD %'3 ض: ValidationSummary − :*אjVאnDD'F¡אlWS' gN37RאX'1\لאIد9אiدאC:ControlToValidate 567 .]1אEو$Uאض:Display .]1אH:ErrorMessage .]1אH 'ن:ForeColor $]وHא\و.Hو،9אnD'،1h K`مH'!FV'م7N،D'F¡אlWS`אن . FووאZP9 א$Q4وא،Hא\وF RequiredFieldValidator : ً I'نPQאن5P>99א CompareValidator :Y71N3''אPQאن$9S$]وHא\وF RegularExpressionValidator : ً RRb'نPQאن$9K>9א RangeValidator : 50و10Y'نPQنC$9Fא ...gB7Rא2j ضNQgNאUو :אKPT'نאPg אصK7LאG´iאدאK0sو،مH'OאFV. :'دPوא ﻛﻮد <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %> 568 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> Name:<br /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="you must eneter Name"></asp:RequiredFieldValidator> <br /> <br /> Age:<br /> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox2" ErrorMessage="Age must be between 10 and 50" MaximumValue="50" MinimumValue="10"></asp:RangeValidator> <br /> <br /> Password:<br /> <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> <br /> <br /> Retype Password:<br /> <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox> <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox3" ControlToValidate="TextBox4" ErrorMessage="The passwords must be the same"></asp:CompareValidator> <br /> <br /> E-mail:<br /> <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox5" ErrorMessage="invalid email address" ValidationExpression="^((?>[a-zA-Z\d!#$%&'*+\/=?^_`{|}~]+\x20*|"((?=[\x01-\x7f])[^"\\]|\\[\x01\x7f])*"\x20*)*(?<angle><))?((?!\.)(?>\.?[a-zA-Z\d!#$%&'*+\/=?^_`{|}~]+)+|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*")@(((?!)[a-zA-Z\d\-]+(?<!-)\.)+[a-zA-Z]{2,}|\[(((?(?<!\[)\.)(25[0-5]|2[04]\d|[01]?\d?\d)){4}|[a-zA-Z\d\-]*[a-zA-Z\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01- 569 \x7f])+)\])(?(angle)>)$"></asp:RegularExpressionValidator> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="Go On" /> <br /> <br /> Summery:r /> <asp:ValidationSummary ID="ValidationSummary1" runat="server" /> </div> </form> </body></html> .g!i$وאKP ControlToValidateאل$Q$RF.و،gN3KP Error Message qF.ً :'S7وسאH$א%אH$.5P_'K>9אF א زمRegularExpression ~א ﻛﻮد ^((?>[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+\x20*|"((?=[\x01-\x7f])[^"\\]|\\[\x01\x7f])*"\x20*)*(?<angle><))?((?!\.)(?>\.?[a-zA-Z\d!#$%&'*+\/=?^_`{|}~]+)+|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*")@(((?!-)[a-zA-Z\d\-]+(?<!)\.)+[a-zA-Z]{2,}|\[(((?(?<!\[)\.)(25[0-5]|2[0-4]\d|[01]?\d?\d)){4}|[a-zA-Z\d\-]*[a-zAZ\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)\])(?(angle)>)$ Range אلUو، ControlToValidateb!s אControlToCompare bI¤Ng!،H7FNو . Maximum Value وMinimum Value *jVI :`N א$S,و،IאzאH]و1Iz1I9אXPHאX%وאن 570 :ﻧﻘﺎط ﺳﺮﻳﻌﺔ :NS 53 Web Parts 5D$Q\!א3NP> رابط http://msdn.microsoft.com/en-us/library/e0s9t4ck.aspx Q$7אKLא، F3VYRY7Q¤NS،ًא$% jא$(Rאng'م7tא3V!A F :NSgND$Q\!א3NP>lWSو، CSS Kאم$+אnD$FQ رابط http://www.w3.org/Style/CSS/learning 571 :NS53g!z$אNP>، Themes fQ3אم$+'אS ASP.net 53zא$א$Q$אKLא رابط http://msdn.microsoft.com/en-us/library/ykzx33wh.aspx State Management .8 אWS K(! 3 q\ OQ . א و¤H$ Desktop Application Q'1 U H{ لI 53 و 0s'אאWS نC9، q\אאWg אصScope جאلHIوאوجC234אzgאn:F7 ً (O) q\א 'م7 نC D א زم53 א نW ، KQ$ ولC 03 h אq\ א. 0M ASP.net U ً 3e o .سH$אאWSU:N7nD fN3'Sو،gD%ZאNP>r. אوq35Q+ :قא53i$'א7א5Q§NP> .View state− .Control state− .Application-Level Variable− .Cache− .Session− .Cookies− Control state .8.1 'وniدאC EnableViewState F7 אq'SD3K،h&O Kgא7Q1 אS א قngF7(O)K( ]و5دوאC53CUi'د%'\א7אLאlWSU،KPROV .ROVא אلªOdאzא$` View State م$+ROVOV\ א5D2N אHTML אلR!' .:F7ViewState 572 ﻛﻮد <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTIxNDIyOTM0Mg9kFgICAw9kFgICAQ8PFgIeBFRleHQFBWFobWVkZ GRkCq8FGqyXBP0pBDpvdnycvM5zSQE=" /> :ﺧﻄﺄ ﺷﺎﺋﻊ م$+ 5QH'1\אGא، Form_Load אلE$U Q$Fj.hQ')zK}'م7جن3ًC :אX'9א C# ﻛﻮد ListBox1.Items.Add("Ahmed"); ListBox1.Items.Add("Mohammed"); ListBox1.Items.Add("Ali"); VB ListBox1.Items.Add("Ahmed") ListBox1.Items.Add("Mohammed") ListBox1.Items.Add("Ali") ﻛﻮد !!!hאi$D. لI53QFj7אzK3ً 'نb'VI،ًא$%37Q1אlWS0.א'אU 53 $] IsPostBack bאم א$+ وא، EnableViewState bI nD دFD9' אS ، KQ$ אKLא אKPTa7!אوi\אUS }'م7 NC C# if (!IsPostBack) { ListBox1.Items.Add("Ahmed"); ListBox1.Items.Add("Mohammed"); ListBox1.Items.Add("Ali"); } ﻛﻮد VB If Not IsPostBack Then ListBox1.Items.Add("Ahmed") ListBox1.Items.Add("Mohammed") ListBox1.Items.Add("Ali") End If ﻛﻮد 573 View state .8.2 5Q+'دאP^ ًא3NP> ،hאدوא5Dًא$5P'موgO\@אOnD$FAIC7Q :7Q1@אON3F. C# ViewState["CustomViewStateItem"] = "Ahmed"; ﻛﻮد VB ViewState("CustomViewStateItem") = "Ahmed" ﻛﻮد ::د9و C# Label1.Text = (string)ViewState["CustomViewStateItem"]; ﻛﻮد VB Label1.Text = DirectCast(ViewState("CustomViewStateItem"), String) ﻛﻮد Session .8.3 :P،a7!NPאf Iא037 אView State 7Q@ONو،ًא$%K3 אg7Q C# Session["mySession"] = "Ahmed"; ﻛﻮد VB Session("mySession") = "Ahmed" ﻛﻮد :iد9وא 574 C# string name = (string) Session["mySession"]; ﻛﻮد VB Dim name As String = DirectCast(Session("mySession"), String) ﻛﻮد :אKPT Session Remove KFD NP> C# Session.Remove["mySession"]; ﻛﻮد VB Session.Remove("mySession") ﻛﻮد 7.د20SًsאZ!وא،j.$:F7 Session &אلO אiZ!د$t وאTimeout bI¤NSنCF C# Session.Timeout = 5; ﻛﻮد VB Session.Timeout = 5 ﻛﻮد Cookies .8.4 )VhO3 U7אlWg&O9אQ،KFزאg%$ND5Pو7&O9אKjو53 AIC7Q ^א7Q1אSو،FאlWS K^}FQKFאOV3'نPQאنiDא3qNQ5Pن(و9אGאU JO א53 7T3 S و، O+\ א0. א\'אU K`'ل وאI$ אh3'} &O9 אU ig, . System.Web.HttpCookie "وאCMI9 א'ن א−א'אن53م$+\אHIאK`'م7N،'PאnDً9^3 אنX`N 'نz'` אQ 9 و، KMO\אم א'ن א$+ אQ ' 'د% وU 0.'F KqT K 03 و،− ً ^3 .ً ^3Ob'אSوsאZ!9א :ObאsאZ!9ً'نא9אوROV'م א7N 575 :g'د אصPא ﻛﻮد <asp:Panel ID="Panel1" runat="server" Height="134px" Width="446px" BackColor="Yellow"> X'1\א'نאHI. :<br /> <br /> <asp:RadioButton ID="RadioButton1" runat="server" Text="MIC" GroupName="colors" /> <br /> <asp:RadioButton ID="RadioButton2" runat="server" oncheckedchanged="RadioButton2_CheckedChanged" Text=""C" GroupName="colors"/> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="1" onclick="Button1_Click1" /> </asp:Panel> ،(1)H زnDaqMאE$UאKPTًH+\א'نא:!نµ'zT'م7N ،وאن :zg ًH'PאאWS1Nو 576 C# string color; if (RadioButton1.Checked) { color = "Green"; Panel1.BackColor = System.Drawing.Color.Green; } else if (RadioButton2.Checked) { color = "Red"; Panel1.BackColor = System.Drawing.Color.Red; } else color = ""; HttpCookie Cookie = new HttpCookie("myColor", color); Cookie.Expires = DateTime.Parse("01/01/2009"); Response.Cookies.Add(Cookie); ﻛﻮد VB Dim color As String If RadioButton1.Checked Then color = "Green" Panel1.BackColor = System.Drawing.Color.Green ElseIf RadioButton2.Checked Then color = "Red" Panel1.BackColor = System.Drawing.Color.Red Else color = "" End If Dim Cookie As New HttpCookie("myColor", color) Cookie.Expires = DateTime.Parse("01/01/2009") Response.Cookies.Add(Cookie) ﻛﻮد !3! myColor 'د%وUو،'Pאizא7'م7N ،KqT Form_Load אلE$Uوאن ::F. C# if (Request.Cookies["myColor"]!=null) { string color = Request.Cookies["myColor"].Value; if (color=="Green") Panel1.BackColor = System.Drawing.Color.Green; else if (color=="Red") Panel1.BackColor = System.Drawing.Color.Red; } ﻛﻮد 577 VB If Request.Cookies("myColor") IsNot Nothing Then Dim color As String = Request.Cookies("myColor").Value If color = "Green" Then Panel1.BackColor = System.Drawing.Color.Green ElseIf color = "Red" Then Panel1.BackColor = System.Drawing.Color.Red End If End If ﻛﻮد Application .8.5 QK، $وאKFhא5Q§Q9k I535Pو، HttpApplicationState 537T3 AIC7Q $NDًאp3'نPQ אنqNQ W وאHدאوא$D'Sk^ل3aא،z Fא0FKV אن5P>h5Q§ .a7!$وאKFD@وz Fא0B :*אjVوאلوא$אnDJO אlWS' ob'א א$وאCbא Fj7$Q$%$Q$%VND !sא Add() i'د%'\אbNא0Bאאض AllKeys i'د%'\אbNدא$D!3 Count D'F¡אKQ$vFم א$DאوvFא Lock(), Unlock() KPאfWوC،Y3وC،N317U VNDfWLم$+ RemoveAt() Remove() RemoveAll() :אKPT$Q$% Application !sאNP> C# Application["Visitors"] = 1; ﻛﻮد VB Application("Visitors") = 1 ﻛﻮد 578 :ً ^3'אنND03Ug אد5P>و C# labelVistor.Text=(string)Application["Visitors"]; ﻛﻮد VB labelVistor.Text = DirectCast(Application("Visitors"), String) ﻛﻮد :ً ^3F. KQ$و C# Application["Visitor"]= ((int)Application["Visitor"])+1; ﻛﻮد VB Application("Visitor") = CInt(Application("Visitor")) + 1 ﻛﻮد ﻣﻼﺣﻈﺔ ... ً بل قد تكون مصفوفة من الفئات مثال، قد ال تكون نص فقطApplication التنس ان محتويات ال Cache .8.6 SzT9 ، k a7! N3 iZ! $Q$ NP> 5P و، z F אig%C 0B $ND 1 V AIC N7 :ً ^3א3مא$+ C# Context.Cache["myCache"] = "hii, my first cache"; ﻛﻮد 579 VB Context.Cache("myCache") = "hii, my first cache" ﻛﻮد :iو د C# string myCache = (string)Context.Cache["myCache"]; ﻛﻮد VB Dim myCache As String = DirectCast(Context.Cache("myCache"), String) ﻛﻮد Global.asax .8.7 5P> ودوאلGlobal h אq35Q+ Global.asax o3אم$+ אS 5Q+'عאs'3UNQ$j%I :אKPTSHI.و$Q$%VND!s.، RObא53g'لb'א :ًא'אدאsאZ!אg$`،ROVאlWk!s א$ 580 C# <%@ Application Language="C#" %> <script runat="server"> void Application_Start(object sender, EventArgs e) { // Code that runs on application startup } ﻛﻮد void Application_End(object sender, EventArgs e) { // Code that runs on application shutdown } void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs } void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started } void Session_End(object sender, EventArgs e) { // Code that runs when a session ends. // Note: The Session_End event is raised only when the sessionstate mode // is set to InProc in the Web.config file. If session mode is set to StateServer // or SQLServer, the event is not raised. } </script> VB <%@ Application Language="VB" %> <script runat="server"> Private Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs on application startup End Sub Private Sub Application_End(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs on application shutdown End Sub Private Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) ﻛﻮد 581 ' Code that runs when an unhandled error occurs End Sub Private Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when a new session is started End Sub Private Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when a session ends. ' Note: The Session_End event is raised only when the sessionstate mode ' is set to InProc in the Web.config file. If session mode is set to StateServer ' or SQLServer, the event is not raised. End Sub </script> State ! א'אع אل03 K3 bI jH وאل$ hOQ nD ROV אlWS ' ، (9 Fو K3 iH אدאU $O دوאل53 S وApplication_Errorz1I אEو$ L !s א، Management O+\ אState Management bN 3א$+ א0B U gN3 iدO9 אNP> و، وعT\ אhROb .سH$אאWSUgD N!tא وﻗﻮاﻋﺪ اﻟﺒﻴﺎﻧﺎتASP.net .9 tאh3'\א53^ ج50.א'אU، ASP.net 03hא$D'א._DUQ'%אنWI]N .NSg71Ntوא، ADO.net وسHدUgF م$+N ، م$+F gD وh אi$D. 53 zC izא7 a7! 'م7Q a 0.'3 KF Qא$ 'م7N אW :K.א9^وC@'دP' אSאWSa7!،lو2N\אאnDًj$3'hi$D. C# SqlConnection cn = new SqlConnection(@"Data Source=AHMEDPC\SQLEXPRESS;Initial Catalog=Items;Integrated Security=True;Pooling=False"); cn.Open(); SqlCommand cmd = new SqlCommand("select * from Items",cn); SqlDataReader dr= cmd.ExecuteReader(); while (dr.Read()) { Response.Write("<b><font color=blue> Item Number: </font></b>" + dr.GetInt64(0).ToString() + "<br/>"); Response.Write("<b><font color=blue> Item Name: </font></b>" + ﻛﻮد 582 dr.GetString(1) + "<br/>"); Response.Write("<b><font color=blue>Item Price: </font></b>" + dr.GetInt64(2).ToString() + "<hr/>"); } VB Dim cn As New SqlConnection("Data Source=AHMED-PC\SQLEXPRESS;Initial Catalog=Items;Integrated Security=True;Pooling=False") cn.Open() Dim cmd As New SqlCommand("select * from Items", cn) Dim dr As SqlDataReader = cmd.ExecuteReader() While dr.Read() ﻛﻮد Response.Write("<b><font color=blue> Item Number: </font></b>" + dr.GetInt64(0).ToString() + "<br/>") Response.Write("<b><font color=blue> Item Name: </font></b>" + dr.GetString(1) + "<br/>") Response.Write("<b><font color=blue>Item Price: </font></b>" + dr.GetInt64(2).ToString() + "<hr/>") End While :2Nوא ، iH'V אaאH K7 h אi$D7 oMN F אول$م א$+N ، ً . אضFD KF`N אن 'نP 'دP א− 2N3 KP gsN t وא234 אH3 @O U iamges $ U H'V אoMN :אKPT 583 ﻛﻮد C# SqlConnection cn = new SqlConnection(@"Data Source=AHMEDPC\SQLEXPRESS;Initial Catalog=Items;Integrated Security=True;Pooling=False"); cn.Open(); SqlCommand cmd = new SqlCommand("select * from Items",cn); SqlDataReader dr= cmd.ExecuteReader(); Response.Write("<center><table border=1><tr valign=center align=center bgcolor=#AAAAAA><td><b>Item No.</b></td><td><b>Item Name</b></td><td><b>Item Price</b></td><td><b>Sample</b></td></tr>"); while (dr.Read()) { Response.Write("<tr><td><b>" + dr.GetInt64(0).ToString() + "</b></td>"); Response.Write("<td>" + dr.GetString(1) + "</td>"); Response.Write("<td>" + dr.GetInt64(2).ToString() + "</td>"); Response.Write(@"<td><img src='images/" + dr.GetString(3) + "'></td></tr>"); } Response.Write("</table></center>"); ﻛﻮد VB Dim cn As New SqlConnection("Data Source=AHMED-PC\SQLEXPRESS;Initial Catalog=Items;Integrated Security=True;Pooling=False") cn.Open() Dim cmd As New SqlCommand("select * from Items", cn) Dim dr As SqlDataReader = cmd.ExecuteReader() Response.Write("<center><table border=1><tr valign=center align=center bgcolor=#AAAAAA><td><b>Item No.</b></td><td><b>Item Name</b></td><td><b>Item Price</b></td><td><b>Sample</b></td></tr>") While dr.Read() Response.Write("<tr><td><b>" + dr.GetInt64(0).ToString() + "</b></td>") Response.Write("<td>" + dr.GetString(1) + "</td>") Response.Write("<td>" + dr.GetInt64(2).ToString() + "</td>") Response.Write("<td><img src='images/" + dr.GetString(3) + "'></td></tr>") End While Response.Write("</table></center>") :ً ^3 אKPT'نP2Nوא 584 ﻣﻼﺣﻈﺔ gRtאh g אnDfNאن، ASP CLassic _DUg71Ntא7Q1@אOSlWS ..net~אN DataGrid .9.1 ...g3K3אنאX`N، ASP.net 03ig,hאhא^אدوאiدא9 אlWS4 SqlDataSource GR. 53و،RאFDK%א533CH*وز03.، DataGrid . :אKPTNو$´g1'م7و 585 . Next aqsא، Connection String אلªOً79N3 G1 :K7LאhQ')!HI.،hאH$V3$Q$N3 G1^^אi'1אU :D'د$ ًא وq3oMNאW،a7!Y30jMאHg&אULمא$+Fطאن,ًMQ א0MN :אKPT*Nא03א0M وControl :] 586 .zgאaqsא، Query {אلNP> a7! NF.W אSqlDataSource 'نאلPk DataSource HI. ، DataGrid אلi'م'د7Nאن :אKPT K.WN3lzT :אWkًgT3ًJ, 'نP2Nא، Enter HزnDaqMوאOم.HאHI.،234`א. ،a7!و 587 : ﺧﺼﺎﺋﺺ اﺿﺎﻓﻴﺔ g(\אSkאو،iאدאlWg7!\! אs9*אjVא5DאنE$RN :אKPT'د%'\אYHI9אNP> و،صI CSS لI53g(\אKQ$NP> ، hROV'د א%' vF אNP> ، GridView iدאC nD O+\ אhF vF אS ، ^ א17Nא :ًMQאGZوאHI9وא 588 :אKPTًJ,'نP 2Nא :אم$+د$¡אK`אizא.NP>،HI E$0sوX`N אن C# string something=GridView1.SelectedRow.Cells[0].ToString(); ﻛﻮد VB Dim something As String something=GridView1.SelectedRow.Cells(0).ToString() ﻛﻮد :*א'אصאjVא5Fs$`N אن :ً ^3אKPT،!s9وאKQ$وאfWLאhF*jVאlWSN F 589 .:! IًضوMQمא$+t وאdetails view وFormView K^3AIאhًאدوאMQ א¤NS :ً ^3 אKPT$Q3Ggjوאi$FD*אjVIUKQ$א5P>،hدوא9אlWSKP K9وس אH$אUS${KbOא.، ASP.net 03hא$D'א._DUQ'%lWS ...ADO.net 590 WAP .10 ft وאProtocol Wireless Application!א\وN7אnDQ'ff'،سH$אאWSU لI53N7אlWS03K3אOسH$אאWS53^אzאUق1NF، WAPًאHVIא .net. ؟WAP ﻣﺎ ﻫﻲ.10.1 : Mobile Application ﺗﻄﺒﻴﻘﺎت اﻟﻤﻮﺑﺎﻳﻞ 3אH'1،lH'g&.و:N3f$kنאF^3Okאh\P\אzא%91لVوאKQ'\א$Q_ K h\P\ אK%C 53 م$+Q KQ'\ א$Q _ و، ً MQC F وg! و3$I وKQ'\ אV אن . S وQ$F\ وא3$7\ אh71אم א$+ وאZ9 אnD 'لI$ אU م$+Q bC ،:אصKqTو(א:وאKQ'\אh71nDل$i$Q$%hR1V3hg&l وGאאWkو aQWوאV+TאhLאnD WEB1V\ً!دא3 WAP1V3hR1V\אlWS5Fs53ون .:3$IوZ_א ؟WAP ﻣﺎ ﻫﻮ ال 9א53s'وאSFو،Wireless Application ProtocolFPHVIאSWAPFP!ً7NOאF طHMobiles7Nאo'אkאig%CaHf$gQ\DStanderdوCH3SWAPאنcQאWS!¦ن . مVN\א ن7א hN 53 ^א oVNא U lQ'1 و ، Z iدON3KFgN3K tوאA4P'لאF[אh,HP!Ch,$'\و''لא4אאWSz%$.و .5QIא5Dol{אUو ؟WAP ﻛﻴﻒ ﺗﻌﻤﻞ ` qViHوMمQ3אWSو،'F[אo'אkאhP3אHאUKFg] WEB5D WAPF V+Tאig%H73'F[אig%bאh\אhאH$.osوDאos03K3وאhא .ًMQCk I53hضאDQtא,T`אqbو 591 l{אUi$Q! gN3KtوאA4P'لאF[אh,h,K_WAPאلN7 لI53و .'F[אgg%CnDZ9אh3$IلIد9ًo :¦!RObGUو،:! Iوo\وC3ROVY3URLلKFאG لI53WAPאلV.C$و WAP و''لאل5Fsg3א$+אQ HTMLKi&N3ضD7QS وWML HTML BQ .אi7OאUgTf'و ...ًMQCHTMLD$RbC'F[אo'אkنאCWQ$وא WML .10.2 U HTML5Do§و، XML Q3nDgNP وHTML KFD7Q1ًא$%gT3hאob'7QS :gN3ط7Nא53د$D אضKg Cardsh.1$N\א7NQ − <html>53ً9$ <wml>'Sj אTag'א− .</card>~ًMQCgN<وcard>~.1KC$ :−Q$PQو53−ً ^3אKPTوذWMLOs'Qً9^3ضNQא$ ﻛﻮد <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//PHONE.COM//DTD WML 1.1//EN" "http://www.phone.com/dtd/wml11.dtd" > <wml> <card id="main" title="First Card"> <p mode="wrap">This is a sample WML page.</p> </card> </wml> : ﻗﺮاءة اﻟﻘﻴﻢ اﻟﻤﺨﺘﻠﻔﺔ وﺗﺨﺰﻳﻨﻬﺎ وﻋﺮﺿﻬﺎ ﻟﻠﻤﺴﺘﺨﺪم :אKPTk.دNوאh אq\אoQNP>KP ﻛﻮد <setvar name="First_Name" value="Ahmed"/> <setvar name="Age" value="21"/> 592 :ً ^3אKPTgsDNP>ً79و ﻛﻮد <p>First Name: $(First_Name)</p> . q\אא53ً9$iאאدא0sوQً3e7Q1@אONSelectوC*03F.izא.ًMQא5P>و :−'ل7N3^ل3–م$+FgsDوHIאiدאC.izא7^ل3 ﻛﻮد <card id="card1" title="Tutorial"> <do type="accept" label="Answer"> <go href="#card2"/> </do> <p> <select name="name"> <option value="HTML">HTML Tutorial</option> <option value="XML">XML Tutorial</option> <option value="WAP">WAP Tutorial</option> </select> </p> </card> <card id="card2" title="Answer"> <p> You selected: $(name) </p> </card> </wml> WAP + ASP.net .10.3 :אKPTنWوא−Q$PQو53'ل7N\א−7\ولאCUlNsDWא1אKQ'RNF.ذא ﻛﻮد <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//PHONE.COM//DTD WML 1.1//EN" "http://www.phone.com/dtd/wml11.dtd" > <wml> <card id="main" title="First Card"> <p mode="wrap">This is a sample WML page.</p> </card> </wml> 593 :אKPT'نPQf'!net.:Q'RNF.و ﻛﻮد <%@ Page Inherits="System.Mobile.UI.MobilePage" Language="C#" %> <%@ Register TagPrefix="mobile" Namespace="System.Mobile.UI" %> <mobile:Form runat="server"> <mobile:Label runat="server"> This is a sample WML page. </mobile:Label> </Mobile:Form> :אKPTVa7!אول1 אVB.net1'אK3אUHU ﻛﻮد <%@ Page Inherits="System.Mobile.UI.MobilePage" Language="C#" %> oSزg%53G1نאUwmlROVאKQ'ً9وCQ،KFאK.53ROVאG$NDوאن .O'3'وCV+,زg%530.'\אGUHTMLi,3KQ'RאQوC،'لF) U א א¡لWS U ^P אKFD P3 زאل3 5P و، NET. لI 53 WAP 1 ^ل3 aC אWS ن 3$7\ אhאH א53 و ذgP3 وאij אאig% אnD f אU و، ً 3'FD 0.'\'ع אs'3 .ًb'VI 594 Ajax .11 ! א\وZ אN7 h3$I 53 iدO9 אO ً Q ضN ASP.net 'لIس אH$א אWS U .net . لI53 AJAX AJAX اﺟﺎﻛﺲ.11.1 وCi$Q$%qg!0.א'אUو، Asynchronous JavaScript and XML FP HVIאS z{ nD @% א$F ، و، AIC 7Q1 i'د%'\د אH'אF אم$+ אS 3 H$. i$Q$% N7 'نPQ53zKFאG$ND:¦! LאlWSUو،i$nD.K3م.אi$DROVא .K3PROVאQ$H(9ًא1M3 وZPא$Q4א53i$Q$ א+N!אs אGmail وZPא$Q4'אS AJAX אم$+^א3Cg,CKو . Hotmail وYahoo ~ :N7אlWS5DQ$PQوRObiHQز01 }H$Q\\!א رابط http://en.wikipedia.org/wiki/Ajax_%28programming%29 ؟.net ﻛﻴﻒ أﺑﺪأ ﻣﻦ ﺧﻼل U \ אhאF\ אnD 'لVL אKg و¤$D t אh אدوא53 ¢ i$D Hא$b !'وPQ3 3. Atlas nFQ3אم$+وC،ًQو$QlH'baCU3א אWgم7א01لQאnDNP،AJAX . AJAX XbI!'وPQ3 53+Sو 595 h אدوא53 D'F S و، Asp.net Ajax ToolKit Hא$b !'وPQ3 3. Kg א53 $QFو aאאאWS لI 53gsאא5P>tאO+\א رابط http://ajax.asp.net/ajaxtoolkit/ :a لאאI53hאدوאlWSKF و0.'\אiHQز01 رابط http://ajax.asp.net/ 4Dg'لb'א5P>،ً3'FD Asp.net ولhאدوאlWkF א\'אدא53F+sP30.'\'!אQF :aא אאWS رابط http://www.asp.net/learn/default.aspx?tabid=63 : ًא$Q$'Q$OאאWS لI53z$ אNP> رابط http://download.microsoft.com/downlo...List-Video.zip . Atlas אم$+אO5DQא$אWN3vT 'م7و :'Q$OאאWSgN3i,3 Ajax ToolKit אم$+z$ אOvTAICوسHد¤NSو رابط http://www.asp.net/learn/videos/view...tabid=63&id=75 http://www.asp.net/learn/videos/view...tabid=63&id=76 ...אولN71KFDUC$N ،وאن 596 53و،ROVאQ$Fe01iH'b!s.ًMQ א،Lא.'א:!*ض03KFDX% : 3אHزU 'دאPאP. C# TextBox1.Text = DateTime.Now.ToString(); ﻛﻮد VB TextBox1.Text = DateTime.Now.ToString() ﻛﻮد Q 9 r z$\@ אO 1 ولRN אن، K3P ROV אQ$ Q KO ، E$d 3 (9 KS . :!KQ$אWאz אnDA' ]א :אKPT@% אhאدوא5Fs53 ScriptManager !sQא$.אW ، جH אU a7! iH'V א¤ 03 gIא$3אH* وزN א03 0s' . و، UpdatePanel GR . אن :אKPTROV'ن'دאP ﻛﻮد <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default6.aspx.cs" Inherits="Default6" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> 597 <form id="form1" runat="server"> <div> <img src="images/food.jpg" /> <asp:UpdatePanel runat="server"><ContentTemplate> <br /> <br /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="ShowTime" /> </ContentTemplate></asp:UpdatePanel> </div> </form> </body> </html> ق! ً؟؟HO(א9 KS،X%وאن update panel ج אلHI39אH ز0s و$Q N אNsZ!ذא 'א3I 'عs'3 1 ولRN אن، KB .5PאWS،:^Q$Q9r : update panel אلKI'دאدאPאP.و، update Panel جאلHI3אHزGRאa7! ﻛﻮد <Triggers> <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" /> </Triggers> :אKPTً 3'دP אV ﻛﻮد <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default6.aspx.cs" Inherits="Default6" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> 598 <img src="images/food.jpg" /> <asp:UpdatePanel runat="server"><ContentTemplate> <br /> <br /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br /> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" /> </Triggers> </asp:UpdatePanel> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="ShowTime" /> </div> </form> </body> </html> ؟AIC i3قHO(א9KS :ﻋﻮدة ﻟﻘﻮاﻋﺪ اﻟﺒﻴﺎﻧﺎت אK7UF.א0sوX%و،ROV אUiH'b0sوX%،hא$D'א. 'لIאN71'دN . Enter nDaqM.وnV.א ل אل1Q Q$R אK`N אN71 U ، K3P ROV אQ$ Q ً MQ א، E$d 3 (9 KS . :Q').]نCدونa7!GridView osא53و،3אHزosא، GridView אلg!0sو، update panel 0s ،lN%Fًא$%a'عs'\א :אKPTK3P'دאPאV،s\سאH$אU 'دF Triggers אل ﻛﻮد <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> 599 <body> <form id="form1" runat="server"> <center> <div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ItemsConnectionString %>" SelectCommand="SELECT * FROM [Items] WHERE ([ItemPrice] < @ItemPrice)"> <SelectParameters> <asp:ControlParameter ControlID="TextBox1" DefaultValue="0" Name="ItemPrice" PropertyName="Text" Type="Int64" /> </SelectParameters> </asp:SqlDataSource> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:TextBox ID="TextBox1" runat="server">1000</asp:TextBox> <asp:Label ID="Label1" runat="server" Text="0jMא5DRא "></asp:Label> <br /> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"> </asp:ScriptManager> <br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" > <ContentTemplate> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" AutoGenerateSelectButton="True" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal" onselectedindexchanged="GridView1_SelectedIndexChanged"> <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" /> <Columns> <asp:CommandField ShowSelectButton="True" /> <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" /> <asp:BoundField DataField="ItemName" HeaderText="ItemName" SortExpression="ItemName" /> <asp:BoundField DataField="ItemPrice" HeaderText="ItemPrice" 600 SortExpression="ItemPrice" /> <asp:BoundField DataField="ItemPicture" HeaderText="ItemPicture" SortExpression="ItemPicture" /> </Columns> <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" /> <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /> <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" /> <AlternatingRowStyle BackColor="#F7F7F7" /> </asp:GridView> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger EventName="Click" ControlID="Button1" /> </Triggers> </asp:UpdatePanel> <br /> <br /> <br /> </div> </center> </form> </body> </html> .قHOאª9و،ROV` א.a7!אن : AJAX Toolkit אאضNP> ، AJAX ¨د3 1 nD ¤$D t אh אدوא53 B D'F !'وPQ3 !' :NS3$7\אhدوא9א رابط http://www.asp.net/ajax/ajaxcontroltoolkit/samples/ :NSS${،FאhS'Q$OאQ5Dg!i$אوא5Dz,K!3 NP> رابط http://www.asp.net/ajax/ajaxcontroltoolkit/ 601 ﺧﺎﺗﻤﺔ اﻟﻜﺘﺎب 602 _DUطא7NאnD'dW وא.net 2008_D03N'%QgNNbو$.'نP$LאאWS . QzT'א\!وiدQزUFS$.'نCنCאًو$O3'نPQنCא53'%HC،.net 2008 :وZPאtو$3nDXPאRObQ5DXPא+InDא عb'א3NP> www.AhmedGamal-Technical.blogspot.com ]1InوC3'\אUوC'دPאU]1ICh$% ً'وM!،QgNאUHC'دوDCQא$אUhذFو Q$ ًא ' ن$ ً ]'نMQ א، وZP א$Q nD : cאH ' i אدQ U !]'نj 3 .XPאאWS537\א¢NאYوQ'1hאZ.א .XPאאWSUcFDودC$DوCS53KPAICi3P,HC .Y\אXH$FLوא .YBC:Rbو:nDو$F)NnDאnbو اﻟﻤﺼﺎدر 603 .Pro C# 2008X− Pro C# 2008 and the .NET 3.5 Platform, Exploring the .NET universe using curly brackets. Aouther: Andrew Troelsen. Edition: Fourth Edition .MSDN− MSDN – Microsft Developer Network, http://msdn2.microsoft.com/en-us/default.aspx .X!`'אلA$N353.O3h973− http://www.vb4arab.com .4אQOאA$N353.O3h973− http://www.arabteam2000-forum.com/ 604 605