毕业论文外文翻译-C#.docx
《毕业论文外文翻译-C#.docx》由会员分享,可在线阅读,更多相关《毕业论文外文翻译-C#.docx(8页珍藏版)》请在冰豆网上搜索。
WhereC#FitsIn
Inonesense,C#canbeseenasbeingthesamethingtoprogramminglanguagesas.NETistotheWindowsenvironment.JustasMicrosofthasbeenaddingmoreandmorefeaturestoWindowsandtheWindowsAPIoverthepastdecade,VisualBasicandC++haveundergoneexpansion.AlthoughVisualBasicandC++haveendedupashugelypowerfullanguagesasaresultofthis,bothlanguagesalsosufferfromproblemsduetothelegaciesofhowtheyhaveevolved.
InthecaseofVisualBasic6andearlier,themainstrengthofthelanguagewasthefactthatitwassimpletounderstandanddidn'tmakemanyprogrammingtaskseasy,largelyhidingthedetailsoftheWindowsAPIandtheCOMcomponentinfrastructurefromthedeveloper.ThedownsidetothiswasthatVisualBasicwasnevertrulyobject-oriented,sothatlargeapplicationsquicklybecomedisorganizedandhardtomaintain.Aswellasthis,becauseVisualBasic'ssyntaxwasinheritedfromearlyversionsofBASIC(which,inturn,wasdesignedtobeintuitivelysimpleforbeginningprogrammerstounderstand,ratherthantowritelargecommercialapplications),itdidn'treallylenditselftowell-structuredorobject-orientedprograms.
C++,ontheotherhand,hasitsrootsintheANSIC++languagedefinition.Itisn'tcompletelyANSIcompliantforthesimplereasonthatMicrosoftfirstwroteitsC++compilerbeforetheANSIdefinitionhadbecomeofficial,butitcomesclose.Unfortunately,thishasledtotwoproblems.First,ANSIC++hasitsrootsinadecade-oldstateoftechnology,andthisshowsupinalackofsupportformodemconcepts(suchasUnicodestringsandgeneratingXMLdocumentation),andinsomearchaicsyntaxstructuresdesignedforthecompilersofyesteryear(suchastheseparationofdeclarationfromdefinitionofmemberfunctions).Second,MicrosofthasbeensimultaneouslytryingtoevolveC++intoalanguagethatisdesignedforhigh-performancetasksonWindows,andinordertoachievethatthey'vebeenforcedtoaddahugenumberofMicrosoft-specifickeywordsaswellasvariouslibrariestothelanguage.
TheresultisthatonWindows,thelanguagehasbecomeacompletemess.JustaskC++developershowmanydefinitionsforastringtheycanthinkof:
char*,LPTSTR,string,CString(MFCversion),CString(WTLversion),wchart*,OLECHAR*,andsoon.
Nowenter.NET一acompletelynewenvironmentthatisgoingtoinvolvenewextensionstobothlanguages.MicrosofthasgottenaroundthisbyaddingyetmoreMicrosoft-specifickeywordstoC++,andbycompletelyrevampingVisualBasicintoVisualBasic.NET,alanguagethatretainssomeofthebasicVBsyntaxbutthatissodifferentindesignthatwecanconsiderittobe,forallpracticalpurposes,anewlanguage.IfsinthiscontextthatMicrosofthasdecidedtogivedevelopersanalternative一alanguagedesignedspecificallyfor.NET,anddesignedwithacleanslate.VisualC#.NETistheresult.Officially,MicrosoftdescribesC#asa"simple,modern,object-oriented,andtype-safeprogramminglanguagederivedfrom
CandC++."Mostindependentobserverswouldprobablychangethatto"derivedfromC,C++,andJava."Suchdescriptionsaretechnicallyaccuratebutdolittletoconveythebeautyoreleganceofthelanguage.Syntactically,C#isverysimilartobothC++andJava,tosuchanextentthatmanykeywordsarethesame,andC#alsosharesthesameblockstructurewithbraces({})tomarkblocksofcode,andsemicolonstoseparatestatements.ThefirstimpressionofapieceofC#codeisthatitlooksquitelikeC++orJavacode.Behindthatinitialsimilarity,however,C#isaloteasiertolearnthanC++,andofcomparabledifficultytoJava.Itsdesignismoreintunewithmodemdevelopertoolsthanbothofthoseotherlanguages,andithasbeendesignedtogiveus,simultaneously,theeaseofuseofVisualBasic,andthehighperformance,low-levelmemoryaccessofC++ifrequired.SomeofthefeaturesofC#are:
□ Fullsupportforclassesandobject-orientedprogramming,includingbothinterfaceandimplementation
inheritance,virtualfunctions,andoperatoroverloading.
□ Aconsistentandwell-definedsetofbasictypes.
□ Built-insupportforautomaticgenerationofXMLdocumentation.
□ Automaticcleanupofdynamicallyallocatedmemory.
□ Thefacilitytomarkclassesormethodswithuser-definedattributes.Thiscanbeusefulfordocumentation
andcanhavesomeeffectsoncompilation(forexample,markingmethodstobecompiledonlyindebugbuilds).
□ Fullaccesstothe.NETbaseclasslibrary,aswellaseasyaccesstotheWindowsAPI(ifyou
reallyneedit,whichwon9tbeallthatoften).
□ Pointersanddirectmemoryaccessareavailableifrequired,butthelanguagehasbeendesigned
insuchawaythatyoucanworkwithouttheminalmostallcases.
□ SupportforpropertiesandeventsinthestyleofVisualBasic.
□ Justbychangingthecompilerop