資源描述:
《C#基礎(chǔ)學(xué)習(xí)英文文檔》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、Chapter1SyntaxofC#Language1.1Object-OrientedProgramminginC#ThefirstsectionintroducestheC#languageandtheprinciplesofobject-orientedprogrammingingeneral.WecoverthesyntaxOfC#andhowtocreatesimpleprograms?Thenwediscussclasses,objects,inheritance,andinterfacesandexplainthefu
2、ndamentalsofUMLdiagrams.BythetimeyoiTvefinishedthisintroductorysection,youshouldfeelquiteathomeinC#and00programmingandreadytolearnhowtouseDesignPatternsinyourprogramming.C#hasallthefeaturesofanypowerful,modernlanguage?IfyouarefamiliarwithJava,C,orC++”you'llfindmostofC#
3、'ssyntaxveryfamilia匚IfyouhavebeenworkinginVisualBasicorrelatedareas,youshouldreadthischaptertoseehowC#differsfromVB.You'llquicklyseethateverymajoroperationyoucancarryoutinVisualBasic.NEThasasimilaroperationinC#?ThetwomajordifferencesbetweenC#andVisualBasicare(l)C#iscas
4、esensitive(mostofitssyntaxiswritteninlowercase),and(2)everystatementinC#isterminatedwithasemicolon(;).Thus,C#statementsarenotconstrainedtoasingleline,andthereisnolinecontinuationcharacter.InVisualBasic,wecouldwritethefollowing?y=m*x+bComputeyforgivenxOrwecouldwritethis
5、.Y=M*X+brcomputeyforgivenxBothwouldbetreatedasthesame.ThevariablesY,M,andXarethesamewhetherwritteninupper-orlowercase.InC#,however,caseissignificant,andifwewritethisConstPI=3.1416AsSingleinVBconstfloatPI=3.1416;//inc#TheconstmodifierinC#meansthatthenamedValueisaconstan
6、tandcannotbemodified.Programmersalsosometimesdefinedatatypeswithmixedcaseandvariablesofthatdatatypewithlowercase.classTemperature{//begindefinitionof//newdatatypeTemperaturetemp;//tempisofthisnewtypeWellcoverclassesinmuchmoredetailinthechaptersthatfollow.1.2DataTypesTh
7、emajordatatypesinC#areshowninTable2?l.Notethelengthsofthesebasictypesarenotrelatedtothecomputertypeoroperatingsystem.CharactersandstringsinC#arealways16bitswidetoallowforrepresentationofcharactersinnon-Latinlanguages?ItusesacharactercodingsystemcalledUnicode,inwhichtho
8、usandsofcharactersformostmajorwrittenlanguageshavebeendefined?Youcanconvertbetweenvariabletypesintheusualways.booltru