版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、Where C# Fits InIn 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 Vi
2、sual 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 didnt
3、 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 well a
4、s this, because Visual Basics 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 didnt really lend itself to well-structured or object-oriented progr
5、ams.C+, on the other hand, has its roots in the ANSI C+ language definition. 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, ANSI
6、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 from defi
7、nition 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 theyve been forced to add a huge number of Microsoft-specific keywords as well as various libraries to the l
8、anguage. 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 .NETa completely new environment t
9、hat 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 in design tha
10、t we can consider it to be, for all practical purposes, a newlanguage. Its in this context that Microsoft 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 C# as a “si
11、mple, modern, object-oriented, and type-safe programming language derived fromC 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. Syntactically,
12、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+ or Java code.
13、 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 Visual Basic, and th
14、e 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 implementationinheritance, virtual functions, and operator overloading. A consistent and well-defined set of basic type
15、s. 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 documentationand can have some effects on compilation (for example, marking methods to be
16、compiled only in debug builds). Full access to the .NET base class library, as well as easy access to the Windows API (if youreally need it, which wont be all that often). Pointers and direct memory access are available if required, but the language has been designedin such a way that you can work w
17、ithout 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 way as ActiveX controls(COM components). C
18、# 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 that its support for the features of .NET is b
19、oth more complete, and offered within the context of a more suitable syntax thanfor 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 environment.Before we leave the subject, we should po
20、int 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 you need to clean up your resources the milliseco
21、nd 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 that are guaranteed to run at particular point
22、s in the code. However, the proportions of applications that fall into this category are very low.出處:Professional C#Third Edition作者:Simon RobinsonChristian NagelJay GlynnMorgan SkinnerKarli WatsonBill EvjenC#C#在某種程度上可以看作是.NET面向Windows環(huán)境的一種編程語言。在過去的十幾年里,Microsoft給Windows和 Windows API添加了許多功能,VB和C+也經(jīng)歷了
23、許多變化。雖然VB和C+最終已成為非常強(qiáng)大的語言,但這兩種語言也存在問題,因?yàn)樗鼈儽A袅嗽瓉淼囊恍﹥?nèi)容。對于Visual Basic來說,它的主要優(yōu)點(diǎn)是很容易理解,許多編程工作都很容易完成,基本上隱藏了Windows API和COM組件結(jié)構(gòu)的內(nèi)涵。其缺點(diǎn)是Visual Basic從來沒有實(shí)現(xiàn)真正意義上的面向?qū)ο?,所以大型?yīng)用程序很難分解和維護(hù)。另外,因?yàn)閂B的語法繼承于BASIC的早期版本(BASIC主要是為了讓初學(xué)者更容易理解,而不是為了編寫大型商業(yè)應(yīng)用程序),所以不能真正成為結(jié)構(gòu)化或面向?qū)ο蟮木幊陶Z言。另一方面,C+在ANSI C+語言定義中有其自己的根。它與ANSI不完全兼容,因?yàn)镸ic
24、rosoft是在ANSI定義標(biāo)準(zhǔn)化之前編寫C+編譯器的,但已經(jīng)相當(dāng)接近了。遺憾的是,這導(dǎo)致了兩個(gè)問題。其一,ANSI C+是在十幾年前的技術(shù)條件下開發(fā)的,因此不支持現(xiàn)在的概念(例如Unicode字符串和生成XML文檔),某些古老的語法結(jié)構(gòu)是為以前的編譯器設(shè)計(jì)的(例如成員函數(shù)的聲明和定義是分開的)。其二,Microsoft同時(shí)還試圖把C+演變?yōu)橐环N用于在Windows上執(zhí)行高性能任務(wù)的語言 在語言中避免添加大量Microsoft專用的關(guān)鍵字和各種庫。其結(jié)果是在Windows中,該語言成為了一種非常雜亂的語言。讓一個(gè)C+開發(fā)人員說說字符串有多少個(gè)定義方式就可以說明這一點(diǎn):char*、LPTSTR、
25、string、CString (MFC 版本)、CString (WTL 版本)、wchar_t*和 OLECHAR*等?,F(xiàn)在進(jìn)入.NET時(shí)代 一種全新的環(huán)境,它對這兩種語言都進(jìn)行了新的擴(kuò)展。Microsoft給C+添加了許多Microsoft專用的關(guān)鍵字,并把VB演變?yōu)閂B.NET,保留了一些基本的VB語法,但在設(shè)計(jì)上完全不同,從實(shí)際應(yīng)用的角度來看,VB.NET是一種新語言。在這里,Microsoft決定給開發(fā)人員另一個(gè)選擇 專門用于.NET、具有新起點(diǎn)的語言, 即Visual C# .NET。Microsoft在正式場合把C#描述為一種簡單、現(xiàn)代、面向?qū)ο?、類型非常安全、派生于C和C+的編程語言。大多數(shù)獨(dú)立的評論員對其說法是“派生于C、 C+ 和Java”。這種描述在技術(shù)上是非常準(zhǔn)確的,但沒有涉及到該語言的真正優(yōu)點(diǎn)。從語法上看,C#非常類似于C+和Java,許多關(guān)鍵字都是相同的,C#也使用類似于C+和Java的塊結(jié)構(gòu),并用括號(hào)()來標(biāo)記代碼塊,用分號(hào)分隔各行語句。對C#代碼的第一印象是它非常類似于C+或Java代碼。但在這
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五版搬運(yùn)企業(yè)節(jié)能減排合同范本3篇
- 2025年度木材加工設(shè)備租賃及維護(hù)服務(wù)合同范本4篇
- 2025版民爆物品裝卸作業(yè)環(huán)境保護(hù)合同4篇
- 2025年度個(gè)人消費(fèi)分期付款合同范本(2025版)3篇
- 農(nóng)業(yè)機(jī)械化與農(nóng)村振興人才培育考核試卷
- 2025版事業(yè)單位聘用合同正規(guī)范本(含試用期)2篇
- 2025版人工智能研發(fā)中心錄用合同范本3篇
- 2025年公益活動(dòng)加盟合同
- 2025年大型活動(dòng)合作協(xié)議
- 2025年度高科技實(shí)驗(yàn)室租賃合同4篇
- 【探跡科技】2024知識(shí)產(chǎn)權(quán)行業(yè)發(fā)展趨勢報(bào)告-從工業(yè)轟鳴到數(shù)智浪潮知識(shí)產(chǎn)權(quán)成為競爭市場的“矛與盾”
- 《中國政法大學(xué)》課件
- GB/T 35270-2024嬰幼兒背帶(袋)
- 遼寧省沈陽名校2025屆高三第一次模擬考試英語試卷含解析
- 2024-2025學(xué)年高二上學(xué)期期末數(shù)學(xué)試卷(新題型:19題)(基礎(chǔ)篇)(含答案)
- 2022版藝術(shù)新課標(biāo)解讀心得(課件)小學(xué)美術(shù)
- Profinet(S523-FANUC)發(fā)那科通訊設(shè)置
- 醫(yī)學(xué)教程 常見化療藥物歸納
- 統(tǒng)編版九年級(jí)歷史下冊第一單元教案教學(xué)設(shè)計(jì)
- GB/T 25000.51-2016系統(tǒng)與軟件工程系統(tǒng)與軟件質(zhì)量要求和評價(jià)(SQuaRE)第51部分:就緒可用軟件產(chǎn)品(RUSP)的質(zhì)量要求和測試細(xì)則
- 外科學(xué)試題庫及答案(共1000題)
評論
0/150
提交評論