c#外文文献以及翻译_第1页
c#外文文献以及翻译_第2页
c#外文文献以及翻译_第3页
c#外文文献以及翻译_第4页
c#外文文献以及翻译_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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环境的一种编程

23、语言。在过去的十几年里, Microsoft 给 Windows 和 Windows API 添 加了许多功能,VB和C+也经历了许多变化。虽然 VB和C+最终 已成为非常强大的语言, 但这两种语言也存在问题, 因为它们保留了 原来的一些内容。 对于 Visual Basic 来说,它的主要优点是很容易理解,许多编程工 作都很容易完成, 基本上隐藏了 Windows API 和 COM 组件结构的内 涵。其缺点是 Visual Basic 从来没有实现真正意义上的面向对象,所 以大型应用程序很难分解和维护。另外,因为 VB 的语法继承于 BASIC的早期版本(BASIC主要是为了让初学者更容易

24、理解,而不是 为了编写大型商业应用程序 ),所以不能真正成为结构化或面向对象 的编程语言 另一方面,C+在ANSI C+语言定义中有其自己的根。它与 ANSI 不完全兼容,因为 Microsoft是在ANSI定义标准化之前编写 C+编 译器的,但已经相当接近了。遗憾的是,这导致了两个问题。其一, ANSI C+是在十几年前的技术条件下开发的,因此不支持现在的概 念(例如 Unicode 字符串和生成 XML 文档),某些古老的语法结构是 为以前的编译器设计的 (例如成员函数的声明和定义是分开的)。其 二,Microsoft同时还试图把C+演变为一种用于在Windows上执行 高性能任务的语言

25、在语言中避免添加大量 Microsoft 专用的关键 字和各种库。其结果是在 Windows 中,该语言成为了一种非常杂乱 的语言。让一个C+开发人员说说字符串有多少个定义方式就可以说 明这一点:char*、LPTSTR、string、CString (MFC 版本)、CString (WTL 版本)、wchar_t*和 OLECHAR* 等。 现在进入.NET时代一一一种全新的环境,它对这两种语言都进行 了新的扩展。 Microsoft 给 C + +添加了许多 Microsoft 专用的关键字, 并把VB演变为VB.NET,保留了一些基本的VB语法,但在设计上 完全不同,从实际应用的角度来

26、看, VB.NET 是一种新语言。 在这里, Microsoft 决定给开发人员另一个选择一 一 专门用于 .NET、 具有新起点的语言, 即 Visual C# .NET。 Microsoft 在正式场合把 C# 描述为一种简单、 现代、面向对象、 类型非常安全、 派生于 C 和 C+ 的编程语言。大多数独立的评论员对其说法是“派生于 C、C+ 和 Java”这种描述在技术上是非常准确的,但没有涉及到该语言的真 正优点。从语法上看,C#非常类似于C+和Java,许多关键字都是 相同的,C#也使用类似于C+和Java的块结构,并用括号()来标 记代码块,用分号分隔各行语句。对C#代码的第一印象是它非常类 似于C+或Java代码。但在这些表面上的类似性后面,C#学习起来 要比C+容

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论