Home Contents
C# is a very popular language. Currently, it is one of the top 10 popular languages in the world. It was created on the Windows platform. The Mono project has created a clone for the Linux and Mac platforms. C# is a compiled language. The source code is compiled into executable (.exe) files which are executed by the .NET platform.
On Linux, we need to install the Mono C# compiler. It is called gmcs for C# 3.0 profile and dmcsfor the C# 4.0 profile. To install the Mono C# compiler, we must install the Mono platform.
On Windows, we have two basic options. We either use the command line compiler or some version of the Visual Studio. The .NET framework is already installed on many versions of Windows OS. If not, we can download it and install it from the microsoft.com website.
On our system, the .NET framework was installed on C:\WINDOWS\Microsoft.NET\Framework\v3.5. Here we find the csc.exe file which is the compiler of the C# language.
Another option is to use a freely available Visual Studio C# Express Edition. We create a new project by selecting File/New Project or clicking Ctrl+N. From the available templates, we select a console application. (All programs in this tutorial are console programs.)
C#
In this part of the C# tutorial, we will introduce the C# programming language.Goal
The goal of this tutorial is to get you started with the C# programming language. The tutorial covers the core of the C# language, including variables, arrays, control structures and other core features. This tutorial uses command line compilers to build applications. It does not cover graphical interface development, or visual IDEs.C#
C# is a modern, high-level, general-purpose, object-oriented programming language. It is the principal language of the .NET framework. It supports functional, procedural, generic, object-oriented, and component-oriented programming disciplines. The design goals of the language were software robustness, durability and programmer productivity. It can be used to create console applications, GUI applications, web applications, both on PCs and embedded systems. C# was created by Microsoft corporation. The name "C sharp" was inspired by musical notation where a sharp indicates that the written note should be made a semitone higher in pitch.C# is a very popular language. Currently, it is one of the top 10 popular languages in the world. It was created on the Windows platform. The Mono project has created a clone for the Linux and Mac platforms. C# is a compiled language. The source code is compiled into executable (.exe) files which are executed by the .NET platform.
.NET
The .NET framework is an application software platform from Microsoft, introduced in 2002 and commonly called .NET ("dot net"). It uses an intermediate bytecode language that can be executed on any hardware platform that has a runtime engine. Programs written for the .NET Framework execute in a software environment, known as the Common Language Runtime (CLR). Common Language Runtime is an application virtual machine that provides services such as security, memory management, and exception handling. The class library and the CLR together constitute the .NET Framework. The .NET framework supports several programming languages. In addition to C#, development is possible in Visual Basic .NET, managed C++, F#, IronPython or IronRuby.Compiling
There are two prominent C# compilers. The Microsoft C# compiler and the Mono C# compiler.using System; public class Simple { static void Main() { Console.WriteLine("This is C#"); } }This is a simple C# program that prints a message to the console.
On Linux, we need to install the Mono C# compiler. It is called gmcs for C# 3.0 profile and dmcsfor the C# 4.0 profile. To install the Mono C# compiler, we must install the Mono platform.
$ dmcs simple.cs $ ./simple.exe This is C#We compile and run a simple C# program on Linux.
On Windows, we have two basic options. We either use the command line compiler or some version of the Visual Studio. The .NET framework is already installed on many versions of Windows OS. If not, we can download it and install it from the microsoft.com website.
On our system, the .NET framework was installed on C:\WINDOWS\Microsoft.NET\Framework\v3.5. Here we find the csc.exe file which is the compiler of the C# language.
C:\programming\csharp>C:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe simple.cs C:\programming\csharp>simple.exe This is C#We compile and run a simple C# program on Windows.
Another option is to use a freely available Visual Studio C# Express Edition. We create a new project by selecting File/New Project or clicking Ctrl+N. From the available templates, we select a console application. (All programs in this tutorial are console programs.)
Figure: Console application
To run an example, we click the Ctrl + F5 key combination.Sources
The following sources were used to create this tutorial:- msdn.com
- wikipedia.org
- C# Language specification