AGE GEND NDA 0 In Introducti oduction on of of C# C# 0 History tory of of C# C# 0 Des esign ign Goals ls 0 Why hy C# C#? : Featu ture res 0 C# C# & Obje ject-Orien Oriented ted Appr proach ch 0 Advan vanta tage ges of of C# C# 0 Applicat plications ions of of C# C# 0 In Introdu oducti ction on to to .Net Net Frame amework work 0 History tory of of .Net Net 0 Des esign ign Featu tures 0 .Net Net Archite chitectur cture 0 .Net Net & Obje ject Orien iented ted Appr proach ch 0 Applicat plication ion of of .NET : GUI 0 Wrapp pping ng Up Up 0 Refe ference ces
IN INTRODUCTIO TRODUCTION N TO TO C# C# 0 C# is is a mult ulti-par paradig adigm program rogramming ming la langua guage ge which which is is bas ased ed on on objec ect- orie ient nted ed and componen mponent-ori orien ented ted program ogrammin ming disc scipl ipline nes. 0 It It pr provide vides a framewor framework for for free in inter termixi mixing ng cons constr truct ucts fr from om different different paradigms digms. 0 It It uses the the “best too tool for for the job” sin ince ce no no one one pa paradig adigm solv olves al all pro problem lems in in the mos ost efficien cient way.
BR BRIEF IEF HI HISTOR STORY 0 C# C# wa was dev eveloped loped by by Microso Microsoft ft wit with Ande nders rs Hej Hejlsb sber erg as as th the pr prin incip cipal al de desig igner ner an and lea lead arc archite hitect, ct, wit within hin it its .NET in initiati itiative ve an and it it made made it its appear pearance nce in in 2000 2000. 0 Ande nders rs Hej Hejls lsber erg an and hi his team eam wanted wanted to to buil uild a new new pr progr ogramming ming languag language that would that would help elp to to wr writ ite cla class ss li librarie aries in in a .NET fram framework work. He He cla claime imed that that C# C# was much uch closer to to C++ in in its desig ign. 0 The The na name "C "C sharp sharp" wa was in inspi spired ed by by mu music ical nota notati tion on wh where ere a sharp sharp in indic dicate ates that the writte ten note sho hould ld be be made de a semit emitone one highe her in in pitch ch. 0 Eve Ever sinc since it its inc ncepti eption, on, C# C# has has contro controversial sially been een sta stated ted as as an an imi imitation tation of of Java Java. Howe However, er, th through ough th the co course rse of of ti time, e, both oth Java Java an and C# C# hav have exhi xhibit ited ed distinct tinct featur tures es which ch suppo upport rt stro trong obje ject-orien iented ted des esign ign principles inciples .
DE DESIGN SIGN GO GOAL ALS 0 C# C# was inten ende ded to to be be a simple mple, mode dern, n, obje ject-orien oriented ted langua uage ge. 0 The The la langua guage ge an and impl implement entati ation had had to to pr provide vide suppo support for for softwar oftware enginee engineerin ing princip principle les li like stro trong ng type type che checkin cking, g, ar array ay bound ounds checking ecking an and automatic omatic garbage ge collect lection ion. 0 Th The la langu guag age was was inten intended ed fo for dev evel elopm opmen ent of of software oftware com componen onents ts sui uita table le for deployment ployment in in distrib tributed uted envir ironme onments ts. 0 Sour Source code code porta portabili lity was as importa mportant nt for for prog ogram ammers ers wh who were ere fami familia iar with C and C+ C++. 0 Support port for inter ernali naliza zati tion on to to adapt pt the soft ftwar ware to to differ ferent ent languag uages es .
WHY WHY C# ? : C# ? : FE FEATURES TURES 0 C# C# is is the first “component - oriented” langua guage ge in in the C/ C/C++ ++ fami mily ly. 0 The big idea ea of of C# C# is is that everything erything is is an an object. 0 C# is is a prog rogra ramm mming ing la langua guage ge tha that direct directly ly ref refle lect cts the the un underly derlying ing Co Comm mmon on Langua anguage ge Infrast frastruct ructure ure (C (CLI LI). Mo Most st of of it its intrins intrinsic ic ty types es co corres rrespond ond to to val alue ue-typ types es imp imple lemen mente ted by by the CLI frame amework rk. 0 Type Type-sa safe fety ty: C# C# is is more more typ type sa safe fe tha than C+ C++. Type Type sa safe fety ty is is the the ex exte tent to to wh which ich a progra gramm mming langu guag age discoura ourage ges or or prevents events type errors ors. 0 C#, #, like C++, but unlike ike Java, va, support orts operat rator or overl erloa oading ing. 0 Ma Manag aged memory ory is is aut autom omat atica call lly ga garbag age co coll llec ecte ted. Garb arbag age col olle lect ctio ion ad addre dresse ses the the pro roble lem of of mem emory ory le leak aks by by fre freeing eing the the prog rogramm rammer er of of res responsi onsibil ilit ity for for rel relea easi sing memory emory that is is no no longe ger needed eded. 0 C# C# provi rovides des prop opert ertie ies as as synta syntact ctic sug sugar ar for for a comm ommon on pat atte tern rn in in wh which ich a pai air of of met ethods, hods, acc ccess ssor or (g (get ette ter) and and muta utato tor (s (set ette ter) en enca capsu sula late te op opera erati tion ons on on a si singl gle at attri tribute ute of of a class.
? : FEATURES …cont. WHY WHY C# C# ? : 0 In In addit addition ion to to th the try... ..ca catch tch cons construct uct to to handle handle excepti xceptions ons, C# C# ha has a try try... ...fi final ally ly cons construct uct to to gua guaran antee tee ex executi ecution on of of the the code code in in the finally lly block, k, wheth ether er an an excep ception ion occurs curs or or not. 0 Unlike Unlike Java, Java, C# C# do does no not have have check checked exc exceptions eptions. This his ha has been een a consci nsciou ous decis ision ion based on on the issue ues of of scalability lability and ver ersi sion onab abilit ity. 0 Mult Multip iple le in inherita eritance nce is is not not suppo supported ted, al alth though ough a cla class ss can impl implement ent any ny num number er of of inte interface faces. Thi his was as a de desig ign decision ion to to avoid avoid compl complic icati ation and nd simp mplify ify architectur hitectural al requi equirem rements ents througho ughout CLI CLI. 0 C# C# suppo supports a strict trict Boolean Boolean dat data type, type, boo ool. Sta State tements ments that that take take condi conditi tions ons, such ch as as while while and nd if, f, req requir uire an an exp expressio ssion of of a type ype that that implem plements ents the true ue opera erator tor, such ch as as the boolea ean type.
C# & O C# & OBJECT JECT ORIENTED IENTED APPRO PROACH CH Structs ucts & Cla Classes (I) I) Interf erfaces aces (II) II) Dele lega gates tes (III) IV) Swit itch ch Statement: tement: Fall ll Th Throug ugh (IV (V) For Each: ch: Co Contr trol l Flo low VI) Vir irtu tual al Methods hods (VI VII) Boxi xing g & Unboxi xing ng (VI I) Co Common on Ty Type System (VII VIII) IX) Generi nerics cs (IX (X) Refle lect ction ion
(I (I) STR ) STRUCTS CTS & CL CLAS ASSE SES S IN IN C# C# 0 In In C# C# structs structs are re very very diffe ifferent rent fr from om cla class sses es. Structs Structs in in C# C# are re des design gned to to enca encapsulate psulate lig ightwe htweigh ght obje jects cts. They They are va value lue types types (not ot re reference ference ty types pes), so so they' y're re passed sed by by value. 0 They are sealed, ed, whic ich means ns they cann nnot ot be be deriv ived ed from or or have any base class ss. 0 Classes sses in in C# C# are dif iffere erent nt from classes sses in in C++ in in the followi owing ways ys: Ther There is is no no access ccess mod modifier ier on on the the name name of of the the base se cla class ss and nd inh nher erita tance nce is is always lways i. i. public ic. A cla class ss ca can on only ly be be der derive ived fr from om on one base se cla lass ss. If If no no ba base se cla class ss is is exp explicitly tly ii. ii. specifie cified, d, then the class ss wil ill automa matica tically lly be be deriv ived ed from System tem.Ob Obje ject ct. In In C++ ++, the the on only ly ty types pes of of cla class ss mem members ers are re va varia iables, les, funct function ions, s, cons constructors, tructors, iii. iii. de destructor structors and nd ope perat rator ove verl rloa oads, ds, C# C# also lso pe perm rmits its de delega legate tes, s, ev events ents and nd propert erties ies. iv. v. The access ess modif ifie iers rs public ic, priv ivate te and protect ected ed have the same me meani ning g as in in C++ but t there re are two addit itio ional nal acces ess s modif ifie iers rs avail ilable: e: (a (a) I Internal ernal (b (b) Protec ecte ted d in internal nal
Recommend
More recommend