c#外文文献以及翻译Word格式.docx
《c#外文文献以及翻译Word格式.docx》由会员分享,可在线阅读,更多相关《c#外文文献以及翻译Word格式.docx(5页珍藏版)》请在冰豆网上搜索。
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,andthisshowsupinalackofsupportformodernconcepts(suchasUnicodestringsandgeneratingXMLdocumentation),andinsomearchaicsyntaxstructuresdesignedforthecompilersofyesteryear(suchastheseparationofdeclarationfromdefinitionofmemberfunctions).Second,MicrosofthasbeensimultaneouslytryingtoevolveC++intoalanguagethatisdesignedforhigh-performancetasksonWindows,andinordertoachievethatthey’vebeenforcedtoaddahugenumberofMicrosoft-specifickeywordsaswellasvariouslibrariestothelanguage.
TheresultisthatonWindows,thelanguagehasbecomeacompletemess.JustaskC++developershowmanydefinitionsforastringtheycanthinkof:
char*,LPTSTR,string,CString(MFCversion),CString(WTLversion),wchar_t*,OLECHAR*,andsoon.
Nowenter.NET—acompletelynewenvironmentthatisgoingtoinvolvenewextensionstobothlanguages.MicrosofthasgottenaroundthisbyaddingyetmoreMicrosoft-specifickeywordstoC++,andbycompletelyrevampingVisualBasicintoVisualBasic.NET,alanguagethatretainssomeofthebasicVBsyntaxbutthatissodifferentindesignthatwecanconsiderittobe,forallpracticalpurposes,anew
language.It’sinthiscontextthatMicrosofthasdecidedtogivedevelopersanalternative—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.Itsdesignismoreintunewithmoderndevelopertoolsthanbothofthoseotherlanguages,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,markingmethodstobe
compiledonlyindebugbuilds).
❑Fullaccesstothe.NETbaseclasslibrary,aswellaseasyaccesstotheWindowsAPI(ifyou
reallyneedit,whichwon’tbeallthatoften).
❑Pointersanddirectmemoryaccessareavailableifrequired,butthelanguagehasbeendesigned
insuchawaythatyoucanworkwithouttheminalmostallcases.
❑SupportforpropertiesandeventsinthestyleofVisualBasic.
❑Justbychangingthecompileroptions,youcancompileeit