1、In one sense, C# can be seen as being the same thing to programming languages as .NET is to theWindows environment. Just as Microsoft has been adding more and more features to Windows and theWindows API over the past decade, Visual Basic and C+ have undergone expansion. Although VisualBasic and C+ h
2、ave ended up as hugely powerful languages as a result of this, both languages also sufferfrom 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 simpleto understand and didnt make many programmin
3、g tasks easy, largely hiding the details of theWindows API and the COM component infrastructure from the developer. The downside to this wasthat Visual Basic was never truly object-oriented, so that large applications quickly become disorganizedand hard to maintain. As well as this, because Visual B
4、asics syntax was inherited from early versions ofBASIC (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 orobject-oriented programs.C+, on the other hand,
5、has its roots in the ANSI C+ language definition. It isnt completely ANSIcompliantfor the simple reason that Microsoft first wrote its C+ compiler before the ANSI definitionhad become official, but it comes close. Unfortunately, this has led to two problems. First, ANSI C+ hasits roots in a decade-o
6、ld 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 structuresdesigned for the compilers of yesteryear (such as the separation of declaration from definition of memberfunctions). Seco
7、nd, Microsoft has been simultaneously trying to evolve C+ into a language that isdesigned for high-performance tasks on Windows, and in order to achieve that theyve been forced toadd a huge number of Microsoft-specific keywords as well as various libraries to the language. Theresult is that on Windo
8、ws, the language has become a complete mess. Just ask C+ developers howmany 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 that is going to involve new extensions
9、 to both languages.Microsoft has gotten around this by adding yet more Microsoft-specific keywords to C+, andby completely revamping Visual Basic into Visual Basic .NET, a language that retains some of the basicVB syntax but that is so different in design that we can consider it to be, for all pract
10、ical purposes, a newlanguage. Its in this context that Microsoft has decided to give developers an alternativea language designedspecifically for .NET, and designed with a clean slate. Visual C# .NET is the result. Officially, Microsoftdescribes C# as a “simple, modern, object-oriented, and type-saf
11、e programming language derived fromC and C+. Most independent observers would probably change that to “derived from C, C+, andJava. Such descriptions are technically accurate but do little to convey the beauty or elegance of the language.Syntactically, C# is very similar to both C+ and Java, to such
12、 an extent that many keywords arethe same, and C# also shares the same block structure with braces () to mark blocks of code, and semicolonsto separate statements. The first impression of a piece of C# code is that it looks quite like C+ orJava code. Behind that initial similarity, however, C# is a
13、lot easier to learn than C+, and of comparabledifficulty 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 the highperformance,low-level memory access of C+ if r
14、equired. 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 types.Built-in support for automatic generation of XML docu
15、mentation.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 becompiled only in debug builds).Full access to the .NET bas
16、e 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 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 eit
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1