In 2000,Microsoft announced its .NET initiative (www.microsoft.com/net), a broad vision for using the Internet and the web in the development, engineering, distribution and use of software. Rather than forcing you to use a single programming language, .NET permits you to create apps in any .NET-compatible language (such as C#, Visual Basic, Visual C++ and many others). Part of the initiative includes Microsoft’s ASP.NET technology.
The .NET Framework executes apps and contains the .NET Framework Class Library, which provides many capabilities that you’ll use to build substantial C# apps quickly and easily. The .NET Framework Class Library has thousands of valuable prebuilt classes that have been tested and tuned to maximize performance. You’ll learn how to create your own classes, but you should re-use the .NET Framework classes whenever possible to speed up the software development process, while enhancing the quality and performance of the software you develop.
1.9.2 Common Language Runtime
The Common Language Runtime (CLR), another key part of the .NET Framework, executes .NET programs and provides functionality to make them easier to develop and debug.
The CLR is a virtual machine (VM)—software that manages the execution of programs and hides from them the underlying operating system and hardware. The source code for programs that are executed and managed by the CLR is called managed code. The CLR provides various services to managed code, such as integrating software components written in different .NET languages, error handling between such components, enhanced security, automatic memory management and more. Unmanaged-code programs do not have access to the CLR’s services, which makes unmanaged code more difficult to write.
Managed code is compiled into machine-specific instructions in the following steps:
1. First, the code is compiled into Microsoft Intermediate Language (MSIL). Code converted into MSIL from other languages and sources can be woven together by the CLR—this allows programmers to work in their preferred .NET programming language. The MSIL for an app’s components is placed into the app’s executable file—the file that causes the computer to perform the app’s tasks.
2. When the app executes, another compiler (known as the just-in-time compiler or JIT compiler) in the CLR translates the MSIL in the executable file into machine-language code (for a particular platform).
3. The machine-language code executes on that platform.
1.9.3 Platform Independence
If the .NET Framework exists and is installed for a platform, that platform can run any .NET program. The ability of a program to run withoutmodification across multiple platforms is known as platform independence. Code written once can be used on another type of computer without modification, saving time and money. In addition, software can target a wider audience. Previously, companies had to decide whether converting their programs to different platformsq—a process called porting—was worth the cost. With .NET, porting programs is no longer an issue, at least once .NET itself has been made available on the platforms.
1.9.4 Language Interoperability
The .NET Framework provides a high level of language interoperability. Because software components written in different .NET languages (such as C# and Visual Basic) are all compiled into MSIL, the components can be combined to create a single unified program.
Thus, MSIL allows the .NET Framework to be language independent. The .NET Framework Class Library can be used by any .NET language. .NET 4.5, which was released in 2012, includes several improvements and new features to make your apps faster and more responsive. It also features .NET forWindows Store Apps—a subset of .NET that’s used to create Windows 8 UI (user interface) style apps.