版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、 Where C# Fits In In one sense, C# can be seen 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+ have undergone expansion. Although
2、Visual Basic and C+ have ended up as hugely powerful languages as a result of this, both languages also suffer from problems due to the legacies of how they have evolved. 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 di
3、dn t make many programming tasks easy, largely hiding the details of the Windows 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 we
4、ll as this, because Visual Basic s syntax was inherited from early versions of BASIC (which, in turn, was designed to be intuitively simple for beginning programmers to understand, rather than to write large commercial applications), it didn t really lend itse-slftrtuocwtuerlel d or object-oriented
5、programs. C+, on the other hand, has its roots in the ANSI C+ language definiiot n. It isnt completely ANSIcompliant for the simple reason 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
6、, ANSI C+ has its roots in a decade-old state of technology, and this shows up in a lack of support for modern concepts (such as Unicode strings and generating XML documentation), and in some archaic syntax structures designed for the compilers of yesteryear (such as the separation of declaration fr
7、om definition of member functions). Second, Microsoft has been simultaneously trying to evolve C+ into a language that is designed for high-performance tasks on Windows, and in order to achieve that they ve been forced to add a huge number of Microsoft-specific keywords as well as various libraries
8、to the language. The result is that on Windows, the language has become a complete mess. Just ask C+ developers how many definitions for a string they can think of:char* , LPTSTR, string , CString (MFC version), CString (WTL version), wchar_t* , OLECHAR, *and so on. Now enter .NET a completely new e
9、nvironment that is going to involve new extensions to both languages. 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 language that retains some of the basic VB syntax but that is so different i
10、n design that we can consider it to be, for all practical purposes, a new language. It s in this ctotnhtaetxMicrosoft has decided to give developers an alternativea language designed specifically for .NET, and designed with a clean slate. Visual C# .NET is the result. Officially, Microsoft describes
11、 C# as a“ simple, modern, object-oriented, 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 beauty or elegance of the language.
12、Syntactically, C# is very similar to both C+ and Java, to such an extent that many keywords are the same, and C# also shares the same block structure with braces( ) to mark blocks of code, and semicolons to separate statements. The first impression of a piece of C# code is that it looks quite like C
13、+ or Java code. Behind that initial similarity, however, C# is a lot easier to learn than C+, and of comparable difficulty to Java. Its design is more in tune with modern developer tools than both of those other languages, and it has been designed to give us, simultaneously, the ease of use of Visua
14、l Basic, and the highperformance, low-level memory access of C+ if required. Some of the features of C# are: ? Full support for classes and object-oriented programming, including both interface and implementation inheritance, virtual functions, and operator overloading. ? A consistent and well-defin
15、ed set of basic types. ? Built-in support for automatic generation of XML documentation. ? Automatic cleanup of dynamically allocated memory. ? The facility to mark classes or methods with user-defined attributes. This can be useful for documentation and can have some effects on compilation (for exa
16、mple, marking methods to be compiled only in debug builds). ? 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). ? Pointers and direct memory access are available if required, but the language has been designe
17、d in such a way that you can work without them in almost all cases. ? Support for properties and events in the style of Visual Basic. ? 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 wa
18、y as ActiveX controls (COM components). ? C# can be used to write ASP.NET dynamic Web pages and XMLWeb services. Most of the above statements, it should be pointed out, do also apply to Visual Basic .NET and Managed C+. The fact that C# is designed from the start to work with .NET, however, means th
19、at its support for the features of .NET is both more complete, and offered within the context of a more suitable syntax than for those other languages. While the C# language itself is very similar to Java, there are some improvements: in particular, Java is not designed to work with the .NET environ
20、ment. Before we leave 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 codethe kind where you really are worried about whether a loop takes 1,000 or 1,050 machine cycles to run through, and yo
21、u 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. C# lacks certain key facilities needed for extremely high performance apps, including the ability to specify inline functions and destructors
22、 that are guaranteed to run at particular points in the code. However, the proportions of applications that fall into this category are very low. 出處: Professional C#Third Edition 作者: Simon Robinson Christian Nagel Jay Glynn Morgan Skinner Karli Watson Bill Evjen C# C#在某種程度上可以看作是.NET面向Windows環(huán)境的一種編程
23、語(yǔ)言。在過(guò)去的十幾年里, Microsoft 給 Windows 和 Windows API 添 加了許多功能,VB和C+也經(jīng)歷了許多變化。雖然 VB和C+最終 已成為非常強(qiáng)大的語(yǔ)言, 但這兩種語(yǔ)言也存在問(wèn)題, 因?yàn)樗鼈儽A袅?原來(lái)的一些內(nèi)容。 對(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)用程序很難分解和維護(hù)。另外,因?yàn)?VB 的語(yǔ)法繼承于 BASIC的早期版本(BASIC主要是為了讓初學(xué)者更容易
24、理解,而不是 為了編寫(xiě)大型商業(yè)應(yīng)用程序 ),所以不能真正成為結(jié)構(gòu)化或面向?qū)ο?的編程語(yǔ)言 另一方面,C+在ANSI C+語(yǔ)言定義中有其自己的根。它與 ANSI 不完全兼容,因?yàn)?Microsoft是在ANSI定義標(biāo)準(zhǔn)化之前編寫(xiě) C+編 譯器的,但已經(jīng)相當(dāng)接近了。遺憾的是,這導(dǎo)致了兩個(gè)問(wèn)題。其一, ANSI 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ǔ)言
25、在語(yǔ)言中避免添加大量 Microsoft 專(zhuān)用的關(guān)鍵 字和各種庫(kù)。其結(jié)果是在 Windows 中,該語(yǔ)言成為了一種非常雜亂 的語(yǔ)言。讓一個(gè)C+開(kāi)發(fā)人員說(shuō)說(shuō)字符串有多少個(gè)定義方式就可以說(shuō) 明這一點(diǎn):char*、LPTSTR、string、CString (MFC 版本)、CString (WTL 版本)、wchar_t*和 OLECHAR* 等。 現(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ì)上 完全不同,從實(shí)際應(yīng)用的角度來(lái)
26、看, VB.NET 是一種新語(yǔ)言。 在這里, 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ǔ)言的真 正優(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+容
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年旅游公司浮動(dòng)抵押合同
- 個(gè)人住宅租借押金及季度租金合同樣本(2024版)一
- 二零二五年度專(zhuān)業(yè)印刷品設(shè)計(jì)、印刷與打印服務(wù)合同3篇
- 事業(yè)單位基本建設(shè)粉刷工程分包合同2024版B版
- 2025年度烘焙連鎖面包磚供應(yīng)鏈合作協(xié)議4篇
- 二零二五年度干股虛擬股分紅激勵(lì)方案合同范本
- 2025年度玩具貨物運(yùn)輸委托服務(wù)協(xié)議
- 二零二五年度物業(yè)小區(qū)個(gè)人承包社區(qū)物業(yè)服務(wù)綜合解決方案協(xié)議
- 2025年度家用空調(diào)拆裝安全操作規(guī)范及應(yīng)急處理合同
- 二零二五年度家政服務(wù)公司保姆雇傭協(xié)議
- 海外資管機(jī)構(gòu)赴上海投資指南(2024版)
- 山東省青島市2023-2024學(xué)年七年級(jí)上學(xué)期期末考試數(shù)學(xué)試題(含答案)
- 墓地銷(xiāo)售計(jì)劃及方案設(shè)計(jì)書(shū)
- 從偏差行為到卓越一生3.0版
- 優(yōu)佳學(xué)案七年級(jí)上冊(cè)歷史
- 鋁箔行業(yè)海外分析
- 紀(jì)委辦案安全培訓(xùn)課件
- 超市連鎖行業(yè)招商策劃
- 城市道路智慧路燈項(xiàng)目 投標(biāo)方案(技術(shù)標(biāo))
- 【公司利潤(rùn)質(zhì)量研究國(guó)內(nèi)外文獻(xiàn)綜述3400字】
- 工行全國(guó)地區(qū)碼
評(píng)論
0/150
提交評(píng)論