c語(yǔ)言外文資料翻譯及原文_第1頁(yè)
已閱讀1頁(yè),還剩13頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、<p><b>  .NET和C#簡(jiǎn)介</b></p><p>  為了理解.NET的重要性,考慮一下近10年來(lái)出現(xiàn)的許多Windows技術(shù)的本質(zhì)會(huì)有一定的幫助。盡管所有的Windows操作系統(tǒng)在表面上看來(lái)完全不同,但從Windows 3.1(1992年)到Windows Server 2003,在內(nèi)核上都有相同的Windows API。在我們轉(zhuǎn)而使用Windows的新版本時(shí),AP

2、I中增加了非常多的新功能,但這是一個(gè)演化和擴(kuò)展API的過(guò)程,并非是替換它。</p><p>  向后兼容性是Windows技術(shù)的極其重要的特性,也是Windows平臺(tái)的一個(gè)長(zhǎng)處,但它有一個(gè)很大的缺點(diǎn)。每次某項(xiàng)技術(shù)進(jìn)行演化,增加了新功能后,都會(huì)比它以前更復(fù)雜。</p><p>  很明顯,對(duì)此必須進(jìn)行改進(jìn)。Microsoft不可能一直擴(kuò)展這些開(kāi)發(fā)工具和語(yǔ)言,使它們?cè)絹?lái)越復(fù)雜,既要保證能跟上最

3、新硬件的發(fā)展步伐,又要與20世紀(jì)90年代初開(kāi)始流行的Windows產(chǎn)品向后兼容。如果要得到一種簡(jiǎn)單而專(zhuān)業(yè)化的語(yǔ)言、環(huán)境和開(kāi)發(fā)工具,讓開(kāi)發(fā)人員輕松地編寫(xiě)優(yōu)秀的軟件,就需要一種新的開(kāi)端。</p><p>  這就是C#和.NET的作用。粗略地說(shuō),.NET是一種在Windows上編程的新架構(gòu)—— 一種新API。C#是一種新語(yǔ)言,它可以利用.NET Framework及其開(kāi)發(fā)環(huán)境中的所有新特性,以及在最近20年來(lái)出現(xiàn)的面

4、向?qū)ο蟮木幊谭椒ā?lt;/p><p>  在繼續(xù)介紹前,必須先說(shuō)明,向后兼容性并沒(méi)有在這個(gè)演化進(jìn)程中失去?,F(xiàn)有的程序仍可以使用,.NET也兼容現(xiàn)有的軟件。軟件組件在Windows上的通信,現(xiàn)在幾乎都是使用COM實(shí)現(xiàn)的。因此,.NET能夠提供現(xiàn)有COM組件的包裝器(wrapper),以便.NET組件與之通信。</p><p>  Microsoft已經(jīng)擴(kuò)展了C++,提供了一種新語(yǔ)言J#,還對(duì)V

5、B進(jìn)行了很多改進(jìn),把它轉(zhuǎn)變成為功能更強(qiáng)大的VB.NET,并允許把用這些語(yǔ)言編寫(xiě)的代碼用于.NET環(huán)境。但這些語(yǔ)言都因有多年演化的痕跡,所以不能完全用現(xiàn)在的技術(shù)來(lái)編寫(xiě)。</p><p>  在使用.NET Framework 1.0和Visual Studio .NET 2002時(shí),要?jiǎng)?chuàng)建可移動(dòng)應(yīng)用程序,就必須下載Microsoft Mobile Internet Toolkit(MMIT)。而現(xiàn)在,有了.NET

6、Framework 1.1和Visual Studio .NET 2003,就可以直接創(chuàng)建可移動(dòng)應(yīng)用程序,不需要下載其他工具包了。</p><p>  在使用Visual Studio .NET 2003創(chuàng)建新項(xiàng)目時(shí),這是顯而易見(jiàn)的。例如,在查看可以創(chuàng)建的C#項(xiàng)目類(lèi)型列表時(shí),會(huì)看到ASP.NET Mobile Web Application和Smart Device Application。ASP.NET Mob

7、ile Web Application項(xiàng)目類(lèi)型可以用于建立基于Web的可移動(dòng)應(yīng)用程序。Smart Device Application項(xiàng)目類(lèi)型可以創(chuàng)建用于Pocket PC或其他Windows CE設(shè)備的應(yīng)用程序。為Windows CE設(shè)備建立的第三方客戶應(yīng)用程序利用的是Compact Framework,這是.NET Framework的刪節(jié)版本。</p><p>  打開(kāi)任何一種可移動(dòng)項(xiàng)目類(lèi)型,系統(tǒng)就會(huì)在Vi

8、sual Studio .NET工具箱中列出一組可用的可移動(dòng)服務(wù)器控件,然后用戶就可以使用這些控件創(chuàng)建應(yīng)用程序。</p><p>  在新的架構(gòu)中,另一個(gè)大的變化是ADO.NET。ADO.NET是訪問(wèn)和處理數(shù)據(jù)的.NET方式,現(xiàn)在它有兩個(gè)新的數(shù)據(jù)提供程序,其中一個(gè)用于ODBC,另一個(gè)用于Oracle。</p><p>  在使用.NET Framework 1.0時(shí),就可以使用ODBC數(shù)據(jù)

9、提供程序,但它需要單獨(dú)下載。另外,一旦下載,這個(gè)數(shù)據(jù)提供程序的命名空間就是Microsoft.Data.Odbc。</p><p>  而在.NET Framework 1.1中,ODBC數(shù)據(jù)提供程序是內(nèi)置的,不需要單獨(dú)下載。而且可以通過(guò)System.Data.Odbc命名空間來(lái)使用ODBC數(shù)據(jù)源,訪問(wèn)ODBC數(shù)據(jù)連接、數(shù)據(jù)適配器和數(shù)據(jù)讀取器對(duì)象。</p><p>  另一個(gè)新的數(shù)據(jù)提供程

10、序用于處理Oracle數(shù)據(jù)庫(kù)。該數(shù)據(jù)庫(kù)在企業(yè)中的應(yīng)用非常廣泛,缺乏Oracle數(shù)據(jù)提供程序常常是.NET進(jìn)入企業(yè)的一大障礙。為了使用這個(gè)新的數(shù)據(jù)提供程序,需要在項(xiàng)目中引用System.Data.OracleClient命名空間。</p><p>  并發(fā)執(zhí)行side-by-side execution是指在同一個(gè)服務(wù)器上運(yùn)行應(yīng)用程序的多個(gè)版本,其中不同的應(yīng)用程序版本使用不同的運(yùn)行庫(kù)版本。Microsoft一直都向

11、開(kāi)發(fā)人員承諾提供這個(gè)功能,但該功能總是很難可視化,因?yàn)橹荒苁褂肍ramework的一個(gè)版本。在發(fā)布了Framework的第2版.NET Framework 1.1后,就可以看到Microsoft提供的這個(gè)功能了?,F(xiàn)在,可以創(chuàng)建.NET應(yīng)用程序面向.NET Framework 1.1的新版本,同時(shí)還可以讓面向.NET Framework 1.0的舊應(yīng)用程序像以前那樣繼續(xù)運(yùn)行。</p><p>  最近,許多Inte

12、rnet使用IP 4運(yùn)行,IP4也稱(chēng)為IPv4。它提供了IP地址,例如255.255.255. 255。.NET Framework 1.1現(xiàn)在支持IPv6,IPv6是在1995年創(chuàng)建的,解決了IPv4所面臨的許多問(wèn)題。如果人們一直采用IPv4,將很快用盡可用的IP地址。</p><p>  .NET Framework 1.1通過(guò)System.Net命名空間支持IPv6,ASP.NET和XML Web服務(wù)也支持

13、IPv6。</p><p>  在升級(jí).NET Framework時(shí),還對(duì)Visual Studio .NET本身進(jìn)行了升級(jí)。注意,在開(kāi)始頁(yè)面上有一些新圖形,該頁(yè)面上對(duì)象的組織方式也有所不同。另外,新IDE最重大的變化是,一旦安裝,就不是簡(jiǎn)單地把Visual Studio .NET 2002升級(jí)為Visual Studio .NET 2003,而是安裝了一個(gè)全新的IDE版本。如果機(jī)器上已經(jīng)安裝了Visual St

14、udio .NET 2002,就會(huì)得到兩個(gè)完全獨(dú)立的VS.NET IDE。這樣,如果要?jiǎng)?chuàng)建和使用面向.NET Framework 1.0的應(yīng)用程序,就使用VS.NET 2002;如果要?jiǎng)?chuàng)建和使用面向.NET Framework 1.1的應(yīng)用程序,就使用VS.NET 2003。</p><p>  還應(yīng)注意,在打開(kāi)用VS.NET 2002創(chuàng)建的項(xiàng)目時(shí),系統(tǒng)會(huì)詢(xún)問(wèn)是否要把項(xiàng)目升級(jí)為VS.NET 2003項(xiàng)目,如果回答

15、“是”,就會(huì)把項(xiàng)目升級(jí)為面向.NET Framework 1.1的應(yīng)用程序。注意,這是一個(gè)不可逆的過(guò)程。</p><p>  除了這些較大的變化之外,在VS.NET 2003的IDE中,Intellisense的智能化程度更高,代碼自動(dòng)完成功能更強(qiáng)。</p><p>  C#在某種程度上可以看作是.NET面向Windows環(huán)境的一種編程語(yǔ)言。在過(guò)去的十幾年里,Microsoft給Windo

16、ws和 Windows API添加了許多功能,VB和C++也經(jīng)歷了許多變化。雖然VB和C++最終已成為非常強(qiáng)大的語(yǔ)言,但這兩種語(yǔ)言也存在問(wèn)題,因?yàn)樗鼈儽A袅嗽瓉?lái)的一些內(nèi)容。</p><p>  對(duì)于Visual Basic來(lái)說(shuō),它的主要優(yōu)點(diǎn)是很容易理解,許多編程工作都很容易完成,基本上隱藏了Windows API和COM組件結(jié)構(gòu)的內(nèi)涵。其缺點(diǎn)是Visual Basic從來(lái)沒(méi)有實(shí)現(xiàn)真正意義上的面向?qū)ο?,所以大型?yīng)用

17、程序很難分解和維護(hù)。另外,因?yàn)閂B的語(yǔ)法繼承于BASIC的早期版本(BASIC主要是為了讓初學(xué)者更容易理解,而不是為了編寫(xiě)大型商業(yè)應(yīng)用程序),所以不能真正成為結(jié)構(gòu)化或面向?qū)ο蟮木幊陶Z(yǔ)言。</p><p>  另一方面,C++在ANSI C++語(yǔ)言定義中有其自己的根。它與ANSI不完全兼容,因?yàn)镸icrosoft是在ANSI定義標(biāo)準(zhǔn)化之前編寫(xiě)C++編譯器的,但已經(jīng)相當(dāng)接近了。遺憾的是,這導(dǎo)致了兩個(gè)問(wèn)題。其一,ANS

18、I C++是在十幾年前的技術(shù)條件下開(kāi)發(fā)的,因此不支持現(xiàn)在的概念(例如Unicode字符串和生成XML文檔),某些古老的語(yǔ)法結(jié)構(gòu)是為以前的編譯器設(shè)計(jì)的(例如成員函數(shù)的聲明和定義是分開(kāi)的)。其二,Microsoft同時(shí)還試圖把C++演變?yōu)橐环N用于在Windows上執(zhí)行高性能任務(wù)的語(yǔ)言—— 在語(yǔ)言中避免添加大量Microsoft專(zhuān)用的關(guān)鍵字和各種庫(kù)。其結(jié)果是在Windows中,該語(yǔ)言成為了一種非常雜亂的語(yǔ)言。讓一個(gè)C++開(kāi)發(fā)人員說(shuō)說(shuō)字符串有多

19、少個(gè)定義方式就可以說(shuō)明這一點(diǎn):char*、LPTSTR、string、CString (MFC 版本)、CString (WTL 版本)、wchar_t*和 OLECHAR*等。</p><p>  現(xiàn)在進(jìn)入.NET時(shí)代—— 一種全新的環(huán)境,它對(duì)這兩種語(yǔ)言都進(jìn)行了新的擴(kuò)展。Microsoft給C++添加了許多Microsoft專(zhuān)用的關(guān)鍵字,并把VB演變?yōu)閂B.NET,保留了一些基本的VB語(yǔ)法,但在設(shè)計(jì)上完全不同,

20、從實(shí)際應(yīng)用的角度來(lái)看,VB.NET是一種新語(yǔ)言。</p><p>  在這里,Microsoft決定給開(kāi)發(fā)人員另一個(gè)選擇—— 專(zhuān)門(mén)用于.NET、具有新起點(diǎn)的語(yǔ)言, 即Visual C# .NET。Microsoft在正式場(chǎng)合把C#描述為一種簡(jiǎn)單、現(xiàn)代、面向?qū)ο?、?lèi)型非常安全、派生于C和C++的編程語(yǔ)言。大多數(shù)獨(dú)立的評(píng)論員對(duì)其說(shuō)法是“派生于C、 C++ 和Java”。這種描述在技術(shù)上是非常準(zhǔn)確的,但沒(méi)有涉及到該語(yǔ)言

21、的真正優(yōu)點(diǎn)。從語(yǔ)法上看,C#非常類(lèi)似于C++和Java,許多關(guān)鍵字都是相同的,C#也使用類(lèi)似于C++和Java的塊結(jié)構(gòu),并用括號(hào)({})來(lái)標(biāo)記代碼塊,用分號(hào)分隔各行語(yǔ)句。對(duì)C#代碼的第一印象是它非常類(lèi)似于C++或Java代碼。但在這些表面上的類(lèi)似性后面,C#學(xué)習(xí)起來(lái)要比C++容易得多,但比Java難一些。其設(shè)計(jì)與現(xiàn)代開(kāi)發(fā)工具的適應(yīng)性要比其他語(yǔ)言更高,它同時(shí)具有Visual Basic的易用性、高性能以及C++的低級(jí)內(nèi)存訪問(wèn)性。C#包括以

22、下一些特性:</p><p>  完全支持類(lèi)和面向?qū)ο缶幊?,包括接口和繼承、虛函數(shù)和運(yùn)算符重載的處理。</p><p>  定義完整、一致的基本類(lèi)型集。</p><p>  對(duì)自動(dòng)生成XML文檔說(shuō)明的內(nèi)置支持。</p><p>  自動(dòng)清理動(dòng)態(tài)分配的內(nèi)存。</p><p>  可以用用戶定義的特性來(lái)標(biāo)記類(lèi)或方法。這可以

23、用于文檔說(shuō)明,對(duì)編譯有一定的影響(例如,把方法標(biāo)記為只在調(diào)試時(shí)編譯)。</p><p>  對(duì).NET基類(lèi)庫(kù)的完全訪問(wèn)權(quán),并易于訪問(wèn)Windows API。</p><p>  可以使用指針和直接內(nèi)存訪問(wèn),但C#語(yǔ)言可以在沒(méi)有它們的條件下訪問(wèn)內(nèi)存。</p><p>  以VB的風(fēng)格支持屬性和事件。</p><p>  改變編譯器選項(xiàng),可以把程

24、序編譯為可執(zhí)行文件或.NET組件庫(kù),該組件庫(kù)可以用與ActiveX控件(COM組件)相同的方式由其他代碼調(diào)用。</p><p>  C#可以用于編寫(xiě)ASP.NET動(dòng)態(tài)Web頁(yè)面和XML Web服務(wù)。</p><p>  應(yīng)該指出,對(duì)于上述大多數(shù)特性,VB.NET和Managed C++也具備。但C#從一開(kāi)始就使用.NET,對(duì).NET特性的支持不僅是完整的,而且提供了比其他語(yǔ)言更合適的語(yǔ)法。

25、C#語(yǔ)言本身非常類(lèi)似于Java,但其中有一些改進(jìn),因?yàn)镴ava并不是為應(yīng)用于.NET環(huán)境而設(shè)計(jì)的。</p><p>  在結(jié)束這個(gè)主題前,還要指出C#的兩個(gè)局限性。其一是該語(yǔ)言不適用于編寫(xiě)時(shí)間急迫或性能非常高的代碼,例如一個(gè)要運(yùn)行1000或1050次的循環(huán),并在不需要這些循環(huán)時(shí),立即清理它們所占用的資源。在這方面,C++可能仍是所有低級(jí)語(yǔ)言中的佼佼者。其二是C#缺乏性能極高的應(yīng)用程序所需要的關(guān)鍵功能,包括保證在代

26、碼的特定地方運(yùn)行的內(nèi)聯(lián)函數(shù)和析構(gòu)函數(shù)。但這類(lèi)應(yīng)用程序非常少。</p><p>  .NET運(yùn)行在Windows 98、2000、XP和2003上,要使用.NET編寫(xiě)代碼,需要安裝.NET SDK,除非使用內(nèi)置了.NET Framework 1.0和1.1的Windows Server 2003。除非要使用文本編輯器或其他第三方開(kāi)發(fā)環(huán)境來(lái)編寫(xiě)C#代碼,否則一般使用Visual Studio .NET 2003。運(yùn)

27、行托管代碼不需要安裝完整的SDK,但需要.NET運(yùn)行庫(kù)。需要把.NET運(yùn)行庫(kù)分布到還沒(méi)有安裝它的客戶機(jī)上。</p><p>  .NET的語(yǔ)言無(wú)關(guān)性還有一些實(shí)際的限制。特別是中間語(yǔ)言在設(shè)計(jì)時(shí)就打算實(shí)現(xiàn)某些特殊的編程方法,這表示.NET語(yǔ)言必須與編程方法兼容,Microsoft為IL選擇的特定道路是傳統(tǒng)的面向?qū)ο蟮木幊?,帶有?lèi)的單一繼承性。</p><p>  除了傳統(tǒng)的面向?qū)ο缶幊掏?,中間

28、語(yǔ)言還引入了接口的概念,它們顯示了在帶有COM的Windows下的第一個(gè)實(shí)現(xiàn)方式。.NET接口與COM接口不同,它們不需要支持任何COM基礎(chǔ)結(jié)構(gòu),例如,它們不是派生自IUnknown,也沒(méi)有對(duì)應(yīng)的GUID。但它們與COM接口共享下述理念:提供一個(gè)契約,實(shí)現(xiàn)給定接口的類(lèi)必須提供該接口指定的方法和屬性的實(shí)現(xiàn)方式。</p><p>  前面介紹了使用.NET意味著要編譯為中間語(yǔ)言,即需要使用傳統(tǒng)的面向?qū)ο蟮姆椒▉?lái)編程。

29、但這并不能提供語(yǔ)言的互操作性。畢竟,C++和Java都使用相同的面向?qū)ο蟮姆缎?,但它們?nèi)圆皇强山换ゲ僮鞯恼Z(yǔ)言。下面需要詳細(xì)探討一下語(yǔ)言互操作性的概念。</p><p>  首先,需要確定一下語(yǔ)言互操作性的含義。畢竟,COM允許以不同語(yǔ)言編寫(xiě)的組件一起工作,即可以調(diào)用彼此的方法。這就足夠了嗎?COM是一個(gè)二進(jìn)制標(biāo)準(zhǔn),允許組件實(shí)例化其他組件,調(diào)用它們的方法或?qū)傩?,而無(wú)需考慮編寫(xiě)相關(guān)組件的語(yǔ)言。但為了實(shí)現(xiàn)這個(gè)功能,每個(gè)

30、對(duì)象都必須通過(guò)COM運(yùn)行庫(kù)來(lái)實(shí)例化,通過(guò)接口來(lái)訪問(wèn)。根據(jù)關(guān)系組件的線程模型,不同線程上內(nèi)存空間和運(yùn)行組件之間要編組數(shù)據(jù),這還可能造成很大的性能損失。在極端情況下,組件駐留在可執(zhí)行文件中,而不是DLL文件中,還必須創(chuàng)建單獨(dú)的過(guò)程來(lái)運(yùn)行它們。重要的是組件要能與其他組件通信,但僅通過(guò)COM運(yùn)行庫(kù)進(jìn)行通信。無(wú)論COM是用于允許使用不同語(yǔ)言的組件直接彼此通信,或者創(chuàng)建彼此的實(shí)例,系統(tǒng)都把COM作為中間件來(lái)處理。不僅如此,COM結(jié)構(gòu)還不允許利用繼承

31、實(shí)現(xiàn),即它喪失了面向?qū)ο缶幊痰脑S多優(yōu)勢(shì)。</p><p>  與其他編程語(yǔ)言一樣,中間語(yǔ)言提供了許多預(yù)定義的基本數(shù)據(jù)類(lèi)型。它的一個(gè)特性是值類(lèi)型和引用類(lèi)型有明顯的區(qū)別。對(duì)于值類(lèi)型,變量直接保存其數(shù)據(jù),而對(duì)于引用類(lèi)型,變量?jī)H保存地址,對(duì)應(yīng)的數(shù)據(jù)可以在該地址中找到。</p><p>  在C++中,引用類(lèi)型類(lèi)似于通過(guò)指針來(lái)訪問(wèn)變量,而在Visual Basic中,與引用類(lèi)型最相似的是對(duì)象,VB6

32、總是通過(guò)引用來(lái)訪問(wèn)對(duì)象。中間語(yǔ)言也有數(shù)據(jù)存儲(chǔ)的規(guī)范:引用類(lèi)型的實(shí)例總是存儲(chǔ)在一個(gè)名為托管堆的內(nèi)存區(qū)域中,值類(lèi)型一般存儲(chǔ)在堆棧中(但如果值類(lèi)型在引用類(lèi)型中聲明為字段,它們就內(nèi)聯(lián)存儲(chǔ)在堆中)。</p><p>  .NET And C# Introduction</p><p>  In order to understand the significance of .NET, it is u

33、seful to remind ourselves of the nature of many of the Windows technologies that have appeared in the past ten years or so. Although they may look quite different on the surface, all of the Windows operating systems from

34、 Windows 3.1 (introduced in 1992) through Windows Server 2003 have the same familiar Windows API at their core. As we’ve progressed through new versions of Windows, huge numbers of new functions have been added to the AP

35、I, b</p><p>  While backward compatibility has been a crucial feature of Windows technologies and one of the strengths of the Windows platform, it does have a big disadvantage. Every time some technology evo

36、lves and adds new features, it ends up a bit more complicated than it was before.</p><p>  It was clear that something had to change. Microsoft couldn’t go on forever extending the same develop- ment tools a

37、nd languages, always making them more and more complex in order to satisfy the conflict- ing demands of keeping up with the newest hardware and maintaining backward compatibility with what was around when Windows first b

38、ecame popular in the early 1990s. There comes a point where you have to start with a clean slate if you want a simple yet sophisticated set of languages, environ- m</p><p>  This fresh start is what C# and .

39、NET are all about. Roughly speaking, .NET is a new framework—a new API—for programming on the Windows platform. Along with the .NET Framework, C# is a new lan- guage that has been designed from scratch to work with .NET,

40、 as well as to take advantage of all the progress in developer environments and in our understanding of object-oriented programming princi- ples that have taken place over the past 20 years.</p><p>  Before

41、we continue, we should make it clear that backward compatibility has not been lost in the pro- cess. Existing programs will continue to work, and .NET was designed with the ability to work with existing software. Communi

42、cation between software components on Windows presently almost entirely takes place using COM. Taking account of this, .NET does have the ability to provide wrappers around existing COM components so that .NET components

43、 can talk to them.</p><p>  It is true that you don’t need to learn C# in order to write code for .NET. Microsoft has extended C++, provided another new language called J#, and made substantial changes to Vi

44、sual Basic to turn it into the more powerful language Visual Basic .NET, in order to allow code written in either of these lan- guages to target the .NET environment. These other languages, however, are hampered by the l

45、egacy of having evolved over the years rather than having been written from the start with today’s te</p><p>  When using the .NET Framework 1.0 and Visual Studio .NET 2002, to be able to build mobile applic

46、a- tions you had to go out and download the Microsoft Mobile Internet Toolkit (MMIT). Now, with the .NET Framework 1.1 and Visual Studio .NET 2003, this is built right in and therefore no separate down- load is required.

47、</p><p>  This is all quite evident when you create a new project using Visual Studio .NET 2003. For instance, when you look at the list of available C# project types you can create, you will find ASP.NET Mo

48、bile Web Application and Smart Device Application. You would use the ASP.NET Mobile Web Application project type to build Web-based mobile applications (as the name describes). Building a Smart Device Application allows

49、you to create applications for the Pocket PC or any other Windows CE device. The th</p><p>  Opening one of these mobile project types, you will then be presented with a list of available mobile server contr

50、ols in the Visual Studio .NET Toolbox that you can then use to build your applications.</p><p>  Another big area of change in the framework is to ADO.NET. ADO.NET, the .NET way of accessing and working with

51、 data, now has two new data providers—one for ODBC and another for Oracle.</p><p>  An ODBC data provider was available when working with the .NET Framework 1.0, but this required a separate download. Also,

52、once downloaded, the namespace for this data provider was Microsoft.Data.Odbc.</p><p>  With the .NET Framework 1.1, the ODBC data provider is built right in, and no separate download is required. You will n

53、ow be able to work with ODBC data sources through the System.Data.Odbc namespace. This also gives you access to ODBC data connection, data adapter, and data reader objects.</p><p>  The other new data provid

54、er is for working with Oracle databases. This database is quite popular in the enterprise space, and the lack of an Oracle data provider often times was a big barrier for .NET to enter this space. To work with this new d

55、ata provider, you will need to make a reference to the System.Data.OracleClient namespace in your project.</p><p>  Side-by-side execution is the ability to run multiple versions of an application on the sam

56、e server where different application versions target different runtime versions. This was always promised to us as developers, but it was always hard to visualize as only one version of the framework was available. With

57、the release of a second version of the framework (.NET Framework 1.1), we can actually see that it is possible to have this capability. Therefore, you can build new versions of your .NET ap</p><p>  Presentl

58、y, much of the Internet runs using IP version 4, also referred to as IPv4. IPv4 gives us IP addresses such as 255.255.255.255. The .NET Framework 1.1 now supports IPv6, which was created in 1995 to address many of the pr

59、oblems that the world was facing with IPv4. Most of the problems deal with the fact that by the world’s continual use of IPv4, we are rapidly running out of available IP addresses.</p><p>  IPv6 is supported

60、 in the .NET Framework 1.1 through the System.Net namespace as well as in ASP.NET and XML Web services.</p><p>  Along with the upgrade to the .NET Framework, Visual Studio .NET itself has also undergone an

61、upgrade. You will notice that there are some new graphics on the Start Page available and that things on this page are organized a little differently. Besides that, the biggest thing to notice with this new IDE is that o

62、nce installed, it does not simply upgrade Visual Studio .NET 2002 to Visual Studio .NET 2003.</p><p>  Instead, it installs a completely new version of the IDE, and if you already have VS.NET 2002 on your ma

63、chine, then you will have two complete VS.NET IDEs on your box. The reason for this is so that if you want to build and work with applications that target the .NET Framework version 1.0, then you will use VS.NET 2002, an

64、d if you want to build and work with applications that target the .NET Framework ver- sion 1.1 then you will use VS.NET 2003.</p><p>  You should also be aware that when you open a project that was built usi

65、ng VS.NET 2002, you will be asked if you want to upgrade the project to be a VS.NET 2003 project. Doing this will then cause the pro- ject to be re-targeted at the .NET Framework 1.1. Be careful about doing this as it is

66、 an irreversible process.</p><p>  Besides these big changes, you will find that VS.NET 2003 is a better IDE with smarter Intellisense and code completion.</p><p>  In one sense, C# can be seen

67、as being the same thing to programming languages as .NET is to the Windows environment. Just as Microsoft has been adding more and more features to Windows and the Windows API over the past decade, Visual Basic and C++ h

68、ave undergone expansion. Although Visual Basic and C++ have ended up as hugely powerful languages as a result of this, both languages also suf- fer from problems due to the legacies of how they have evolved.</p>&

69、lt;p>  In the case of Visual Basic 6 and earlier, the main strength of the language was the fact that it was simple to understand and didn’t make many programming tasks easy, largely hiding the details of the Windows

70、API and the COM component infrastructure from the developer. The downside to this was that Visual Basic was never truly object-oriented, so that large applications quickly become disorganized and hard to maintain. As wel

71、l as this, because Visual Basic’s syntax was inherited from early vers</p><p>  C++, on the other hand, has its roots in the ANSI C++ language definition. It isn’t completely ANSI- compliant for the simple r

72、eason that Microsoft first wrote its C++ compiler before the ANSI definition had become official, but it comes close. Unfortunately, this has led to two problems. First, ANSI C++ has its roots in a decade-old state of te

73、chnology, and this shows up in a lack of support for modern concepts(such as Unicode strings and generating XML documentation), and in some archaic synta</p><p>  Now enter .NET—a completely new environment

74、that is going to involve new extensions to both lan- guages. Microsoft has gotten around this by adding yet more Microsoft-specific keywords to C++, and by completely revamping Visual Basic into Visual Basic .NET, a lang

75、uage that retains some of the basic VB syntax but that is so different in design that we can consider it to be, for all practical purposes, a new language.</p><p>  It’s in this context that Microsoft has de

76、cided to give developers an alternative—a language designed specifically for .NET, and designed with a clean slate. Visual C# .NET is the result. Officially, Microsoft describes C# as a “simple, modern, object-oriented,

77、and type-safe programming language derived from C and C++.” Most independent observers would probably change that to “derived from C, C++, and Java.” Such descriptions are technically accurate but do little to convey the

78、 beauty or eleganc</p><p>  Full support for classes and object-oriented programming, including both interface and imple- mentation inheritance, virtual functions, and operator overloading.</p><p&

79、gt;  A consistent and well-defined set of basic types.</p><p>  Built-in support for automatic generation of XML documentation.</p><p>  Automatic cleanup of dynamically allocated memory.</p&

80、gt;<p>  The facility to mark classes or methods with user-defined attributes. This can be useful for doc- umentation and can have some effects on compilation (for example, marking methods to be compiled only in d

81、ebug builds).</p><p>  Full access to the .NET base class library, as well as easy access to the Windows API (if you really need it, which won’t be all that often).</p><p>  Pointers and direct

82、memory access are available if required, but the language has been designed in such a way that you can work without them in almost all cases.</p><p>  Support for properties and events in the style of Visual

83、 Basic.</p><p>  Just by changing the compiler options, you can compile either to an executable or to a library of .NET components that can be called up by other code in the same way as ActiveX controls(COM

84、components).</p><p>  C# can be used to write ASP.NET dynamic Web pages and XML Web services.</p><p>  Most of the above statements, it should be pointed out, do also apply to Visual Basic .NET

85、and Managed C++. The fact that C# is designed from the start to work with .NET, however, means that its support for the features of .NET is both more complete, and offered within the context of a more suitable syntax tha

86、n for those other languages. While the C# language itself is very similar to Java, there are some improve- ments: in particular, Java is not designed to work with the .NET environment.</p><p>  Before we lea

87、ve the subject, we should point out a couple of limitations of C#. The one area the language is not designed for is time-critical or extremely high performance code—the kind where you really are worried about whether a l

88、oop takes 1,000 or 1,050 machine cycles to run through, and you need to clean up your resources the millisecond they are no longer needed. C++ is likely to continue to reign supreme among low-level languages in this area

89、. C# lacks certain key facilities needed for ex</p><p>  .NET will run on Windows 98, 2000, XP, and 2003. In order to write code using .NET, you will need to install the .NET SDK unless you are using Windows

90、 Server 2003, which comes with the .NET Framework 1.0 and 1.1 already installed. Unless you are intending to write your C# code using a text editor or some other third party developer environment, you will almost certain

91、ly also want Visual Studio .NET 2003. The full SDK isn’t needed to run managed code, but the .NET runtime is needed. You may find </p><p>  The language independence of .NET does have some practical limitati

92、ons. IL is inevitably going to imple- ment some particular programming methodology, which means that languages targeting it are going to have to be compatible with that methodology. The particular route that Microsoft ha

93、s chosen to follow for IL is that of classic object-oriented programming, with single implementation inheritance of classes.</p><p>  Besides classic object-oriented programming, IL also brings in the idea o

94、f interfaces, which saw their first implementation under Windows with COM. .NET interfaces are not the same as COM interfaces; they do not need to support any of the COM infrastructure (for example, they are not derived

95、from IUnknown, and they do not have associated GUIDs). However, they do share with COM interfaces the idea that they provide a contract, and classes that implement a given interface must provide implementati</p>&

96、lt;p>  We have now seen that working with .NET means compiling to IL, and that in turn means that you will need to use traditional object-oriented methodologies. However, that alone is not sufficient to give us langua

97、ge interoperability. After all, C++ and Java both use the same object-oriented paradigms, but they are still not regarded as interoperable. We need to look a little more closely at the concept of language interoperabilit

98、y.</p><p>  To start with, we need to consider exactly what we mean by language interoperability. After all, COM allowed components written in different languages to work together in the sense of calling eac

99、h other’s methods. What was inadequate about that? COM, by virtue of being a binary standard, did allow compo- nents to instantiate other components and call methods or properties against them, without worrying about the

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫(kù)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論