Название: Professional C# 6 and .NET Core 1.0
Автор: Christian Nagel
Издательство: John Wiley & Sons Limited
Жанр: Зарубежная образовательная литература
isbn: 9781119096634
isbn:
The following sections cover the details of this table and the progress of C# and .NET.
C# 1.0 – A New Language
C# 1.0 was a completely new programming language designed for the .NET Framework. At the time it was developed, the .NET Framework consisted of about 3,000 classes and the CLR.
After Microsoft was not allowed by a court order (filed by Sun, the company that created Java) to make changes to the Java code, Anders Hejlsberg designed C#. Before working for Microsoft, Hejlsberg had his roots at Borland where he designed the Delphi programming language (an Object Pascal dialect). At Microsoft he was responsible for J++ (Microsoft’s version of the Java programming language). Given Hejlsberg’s background, the C# programming language was mainly influenced by C++, Java, and Pascal.
Because C# was created later than Java and C++, Microsoft analyzed typical programming errors that happened with the other languages, and did some things differently to avoid these errors. Some differences include the following:
• With if statements, Boolean expressions are required (C++ allows an integer value here as well).
• It’s permissible to create value and reference types using the struct and class keywords (Java only allows creating custom reference types; with C++ the distinction between struct and class is only the default for the access modifier).
• Virtual and non-virtual methods are allowed (this is similar to C++; Java always creates virtual methods).
Of course there are a lot more changes as you’ll see reading this book.
At this time, C# was a pure object-oriented programming language with features for inheritance, encapsulation, and polymorphism. C# also offered component-based programming enhancements such as delegates and events.
Before the existence of .NET with the CLR, every programming language had its own runtime. With C++, the C++ Runtime is linked with every C++ program. Visual Basic 6 had its own runtime with VBRun. The runtime of Java is the Java Virtual Machine – which can be compared to the CLR. The CLR is a runtime that is used by every .NET programming language. At the time the CLR appeared on the scene, Microsoft offered JScript.NET, Visual Basic .NET, and Managed C++ in addition to C#. JScript.NET was Microsoft’s JavaScript compiler that was to be used with the CLR and .NET classes. Visual Basic.NET was the name for Visual Basic that offered .NET support. Nowadays it’s just called Visual Basic again. Managed C++ was the name for a language that mixed native C++ code with Managed .NET Code. The newer C++ language used today with .NET is C++/CLR.
A compiler for a .NET programming language generates Intermediate Language (IL) code. The IL code looks like object-oriented machine code and can be checked by using the tool ildasm.exe to open DLL or EXE files that contain .NET code. The CLR contains a just-in-time (JIT) compiler that generates native code out of the IL code when the program starts to run.
NOTE IL code is also known as managed code.
Other parts of the CLR are a garbage collector (GC), which is responsible for cleaning up managed memory that is no longer referenced; a security mechanism that uses code access security to verify what code is allowed to do; an extension for the debugger to allow a debug session between different programming languages (for example, starting a debug session with Visual Basic and continuing to debug within a C# library); and a threading facility that is responsible for creating threads on the underlying platform.
The .NET Framework was already huge with version 1. The classes are organized within namespaces to help facilitate navigating the 3,000 available classes. Namespaces are used to group classes and to solve conflicts by allowing the same class name in different namespaces. Version 1 of the .NET Framework allowed creating Windows desktop applications using Windows Forms (namespace System.Windows.Forms), creating web applications with ASP.NET Web Forms (System.Web), communicating with applications and web services using ASP.NET Web Services, communicating more quickly between .NET applications using .NET Remoting, and creating COM+ components for running in an application server using Enterprise Services.
ASP.NET Web Forms was the technology for creating web applications with the goal for the developer to not need to know something about HTML and JavaScript. Server-side controls that worked similarly to Windows Forms itself created HTML and JavaScript.
C# 1.2 and .NET 1.1 was mainly a bug fix release with minor enhancements.
NOTE Inheritance is discussed in Chapter 4, “Inheritance”; delegates and events are covered in Chapter 9, “Delegates, Lambdas, and Events.”
NOTE Every new release of .NET has been accompanied by a new version of the book Professional C#. With .NET 1.0, the book was already in the second edition as the first edition had been published with Beta 2 of .NET 1.0. You’re holding the 10th edition of this book in your hands.
C# 2 and .NET 2 with Generics
C# 2 and .NET 2 was a huge update. With this version, a change to both the C# programming language and the IL code had been made; that’s why a new CLR was needed to support the IL code additions. One big change was generics. Generics make it possible to create types without needing to know what inner types are used. The inner types used are defined at instantiation time, when an instance is created.
This advance in the C# programming language also resulted in many new types in the Framework – for example, new generic collection classes found in the namespace System.Collections.Generic. With this, the older collection classes defined with 1.0 are rarely used with newer applications. Of course, the older classes still work nowadays, even with the new .NET Core version.
NOTE Generics are used all through the book, but they’re explained in detail in Chapter 6, “Generics.” Chapter 11, “Collections,” covers generic collection classes.
.NET 3 – Windows Presentation Foundation
With the release of .NET 3.0 no new version of C# was needed. 3.0 was only a release offering new libraries, but it was a huge release with many new types and namespaces. Windows Presentation Foundation (WPF) was probably the biggest part of the new Framework for creating Windows desktop applications. Windows Forms wrapped the native Windows controls and was based on pixels, whereas WPF was based on DirectX to draw every control on its own. The vector graphics in WPF allow seamless resizing of every form. The templates in WPF also allow for complete custom looks. For example, an application for the Zurich airport can include a button that looks like a plane. As a result, applications can look very different from the traditional Windows applications that had been developed up to that time. Everything below the namespace System.Windows belongs to WPF, with the exception of System.Windows.Forms. With WPF the user interface can be designed using an XML syntax: XML for Applications Markup Language (XAML).
Before .NET 3, ASP.NET Web Services and .NET Remoting were used for communicating between applications. Message Queuing was another option for communicating. The various technologies had different advantages and disadvantages, and all had different APIs for programming. A typical enterprise application had to use more than one communication API, and thus it was necessary to learn several of them. This was solved with Windows Communication Foundation (WCF). WCF combined all the options of the other APIs into the one API. However, to support all of the features WCF has to offer, you need to configure WCF.
The third big part of the .NET 3.0 release was Windows Workflow Foundation (WF) with the namespace System.Workflow. Instead of creating custom workflow СКАЧАТЬ