The Whole File: C# tutorial

What is C#?

C# (pronounced “see sharp” or “C Sharp”) is one of many .NET programming languages. It is object-oriented and allows you to build reusable components for a wide variety of application types Microsoft introduced C# on June 26th, 2000 and it became a v1.0 product on Feb 13th 2002.

C# is an evolution of the C and C++ family of languages. However, it borrows features from other programming languages, such as Delphi and Java. If you look at the most basic syntax of both C# and Java, the code looks very similar, but then again, the code looks a lot like C++ too, which is intentional. Developers often ask questions about why C# supports certain features or works in a certain way. The answer is often rooted in it’s C++ heritage.

How Does a C# Application Run?

An important point is that C# is a “managed” language, meaning that it requires the .NET Common Language Runtime (CLR) to execute. Essentially, as an application that is written in C# executes, the CLR is managing memory, performing garbage collection, handling exceptions, and providing many more services that you, as a developer, don’t have to write code for. The C# compiler produces Intermediate Language (IL) , rather than machine language, and the CLR understands IL. When the CLR sees the IL, it Just-In-Time (JIT) compiles it, method by method, into compiled machine code in memory and executes it. As mentiond previously, the CLR manages the code as it executes.

Because C# requires the CLR, you must have the CLR installed on your system. All new Windows operating systems ship with a version of the CLR and it is available via Windows Update for older systems. The CLR is part of the .NET, so if you see updates for the .NET Framework Runtime, it contains the CLR and .NET Framework Class Library (FCL). It follows that if you copy your C# application to another machine, then that machine must have the CLR installed too.

Does C# Have a Runtime Library?

Instead of a runtime library (such as APIs for file I/O, string handling, etc.) being dedicated to a single language, .NET ships with a .NET Framework Class Library (FCL), which includes literally tens of thousands of reusable objects. Since all .NET languages target the CLR with the same IL, all languages can use the FCL. This shortens the learning curve for any developer moving from one .NET language to another, but also means that Microsoft is able to add many more fea,tures because there is only one FCL, rather than a separate implementation for common features in every programming language. Similarly, 3rd party software vendors can write managed code that any .NET developer, regardless of language, can use. In addition to all of the services you would expect of a runtime library, such as collections, file I/O, networking, etc., the FCL includes the APIs for all of the other .NET technologies, such as for desktop and Web development.

What can I do with C#?

C# is only a programming language. However, because C# targets the CLR and has access to the entire FCL, there’s a lot you can do. To get an idea of the possibilities, open the FCL and look at the available technologies. You can write desktop applications with Windows Forms, Windows Presentation Foundation (WPF), or even Console applications. For the Web, you can write ASP.NET and Silverlight applications in addition to enabling systems to communicate with Web Services with Windows Communications Foundation (WCF). When you need to access data, there is both ADO.NET and LINQ. Some of Microsoft’s newest technologies include Windows 8, Windows Phone 8, and Windows Windows Azure. Of course, these are only a few of the technologies available and as a general purpose programming language, you can do a lot more than this with C#.

How Do I Get Started?

By visiting this page and reading this far, you’ve already begun.  You can continue your journey with the Free C# Tutorial right here. The C# Tutorial was created to help beginning developers and other professionals who need a quick on-ramp to the language.