c#外文文献以及翻译

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

WhereC#FitsInInonesense,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,anewlanguage.It’sinthiscontextthatMicrosofthasdecidedtogivedevelopersanalternative—alanguagedesignedspecificallyfor.NET,anddesignedwithacleanslate.VisualC#.NETistheresult.Officially,MicrosoftdescribesC#asa“simple,modern,object-oriented,andtype-safeprogramminglanguagederivedfromCandC++.”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,includingbothinterfaceandimplementationinheritance,virtualfunctions,andoperatoroverloading.❑Aconsistentandwell-definedsetofbasictypes.❑Built-insupportforautomaticgenerationofXMLdocumentation.❑Automaticcleanupofdynamicallyallocatedmemory.❑Thefacilitytomarkclassesormethodswithuser-definedattributes.Thiscanbeusefulfordocumentationandcanhavesomeeffectsoncompilation(forexample,markingmethodstobecompiledonlyindebugbuilds).❑Fullaccesstothe.NETbaseclasslibrary,aswellaseasyaccesstotheWindowsAPI(ifyoureallyneedit,whichwon’tbeallthatoften).❑Pointersanddirectmemoryaccessareavailableifrequired,butthelanguagehasbeendesignedinsuchawaythatyoucanworkwithouttheminalmostallcases.❑SupportforpropertiesandeventsinthestyleofVisualBasic.❑Justbychangingthecompileroptions,youcancompileeithertoanexecutableortoalibraryof.NETcomponentsthatcanbecalledupbyothercodeinthesamewayasActiveXcontrols(COMcomponents).❑C#canbeusedtowriteASP.NETdynamicWebpagesandXMLWebservices.Mostoftheabovestatements,itshouldbepointedout,doalsoapplytoVisualBasic.NETandManagedC++.ThefactthatC#isdesignedfromthestarttoworkwith.NET,however,meansthatitssupportforthefeaturesof.NETisbothmorecomplete,andofferedwithinthecontextofamoresuitablesyntaxthanforthoseotherlanguages.WhiletheC#languageitselfisverysimilartoJava,therearesomeimprovements:inparticular,Javaisnotdesignedtoworkwiththe.NETenvironment.Beforeweleavethesubject,weshouldpointoutacoupleoflimitationsofC#.Theoneareathelanguageisnotdesignedforistime-criticalorextremelyhighperformancecode—thekindwhereyoureallyareworriedaboutwhetheralooptakes1,000or1,050machinecyclestorunthr

1 / 7
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功