C# and the .NET Framework

The C# programming language was designed to be powerful, safe, and easy to use. As part of the .NET initiative, C# was designed to work seamlessly with the .NET Framework, creating a new way of writing reliable software for the fastest servers, the smallest mobile devices, and everything in between.

Unlike traditional C and C++ code, C# code is not compiled directly into machine language. The C# compiler converts C# source code into Microsoft intermediate language (MSIL) files, called assemblies. MSIL files are created by all languages that build on the common language runtime (CLR), including Visual C++, which can also create native machine code and Visual Basic. In fact, the MSIL produced is in most cases virtually identical from language to language, making it straightforward to combine different program components written in different languages.

The following diagram shows how the C# code you write is converted into an executable application:

From C# source code to machine execution

The MSIL files appear as standard .exe or .dll files, but rather than running directly on the Windows platform, they are executed by the CLR. The CLR compiles the MSIL program into machine code when required; a process called Just-In-Time (JIT) compilation. This machine code is then executed directly. By generating intermediate, hardware-neutral code that is not converted into machine code until the last moment, safety, security, and portability are all increased. This process is largely hidden from the programmer: C# programs are compiled, executed, and distributed in the same way as any other program. As long as the .NET Framework is installed on a computer, the C# program will run like any other application.

It is also worth noting that in some cases it is desirable to permanently convert a C# assembly into machine language, and you can do this with the Native Image Generator (ngen.exe) tool that ships with Visual Studio.

Because it was designed in conjunction with the .NET Framework, C# is exceptionally well suited for .NET development. The .NET Framework class library is an extensive collection of classes that provide your applications with almost everything you could need to develop applications, such as text and graphics display functionality, collections for storing data, tools for manipulating XML files and databases, methods for accessing Web sites, and much more.

The .NET Framework organizes its features by namespaces, each of which typically contains several classes. For example, the System.IO namespace includes many classes for reading and writing files, and the System.Text namespace contains many classes that handle string data. Browse the .NET Framework class library reference documentation to get an idea of the various namespaces and what they contain.

See Also

Tasks

How to: Build a C# Application in 60 Seconds

Concepts

Visual C# Express Features

Reference

C# Compared to Other Languages

Other Resources

Visual C# Express

Getting Started with Visual C# Express