Introduction to C#Setting everything up

C# is a programming language that can be understood as a sort of an evolution of C++, just as Java. In fact, the sharp symbol comes from the two plus signs in C++. It is an object oriented language that has been developed by Microsoft for the .NET platform. Although it was pretty much a a rip-off of Java at its beginnings (it even had a "mascot"), today both have evolved in very different ways.

This site will show you how to use C# to build your applications, from console applications to basic Windows Forms.

Downloading the IDE: Visual Studio

The IDE used to compile and run the examples is Visual Studio 2012. Visual Studio comes in free versions, like Visual Studio 2013, which you can download from the Visual Studio site, and the installation is pretty straight-forward.

Creating a new file in Visual Studio

We are going to be creating a bunch of different snippets. Let's start with the easiest: a console application, that is, an application that runs in your terminal. Go to File > New > Console application. This will open the editor, populate a new project, and open a Program.cs file ready to edit. C# files have a .cs extension. In the next section you will learn the basics of C# and be able to write some code. Visual Studio has IntelliSense enabled by default, which is very useful to complete commands and help you type faster without human syntax errors.

Compiling and running files

To compile and run, click the green "play" button. If you had any errors, it will complain and point them in the code. If not, it will run normally. Since we are creating a console application, this will open your command prompt to run it. This prompt will probably be MS-DOS, if you don't like it (and I won't blame you) you could tell Visual Studio to use a custom console. However that can have some unwanted effects, specially when debugging.

Changing the syntax highlighter

Visual Studio comes with a light and a dark theme for the GUI, but the themes also change the program's syntax highlighter. If you don't like them, you can find lots of themes on the web, and they are easy to install. All you need is a file with extension .vssettings, whose contents are written in XML, then follow these steps:

  • In Visual Studio, choose Tools > Import and Export Settings.
  • Choose Import Selected Environment Settings and select whether you want to back up your existing settings or not.
  • Click Browse... and find the .vssettings file.
  • Choose the settings you want to import.
  • Click Finish.

One of my favourite dark themes is Hopscotch, which I discovered through amazing C. J. Silverio on twitter. You can download it from it's GitHub repo (which contains files for other editors too), and looks like this when used with Visual Studio's dark theme:

Isn't it awesome?

Changing the look of your application (advanced)

Later on, we will be creating applications with a GUI. If you don't like the default system's windows design, you can try installing libraries like metro, which mimics Windows 8 style and is quite popular.

Multi-Line Editing

If you ever worked with NEdit (Nirvana editor) before, you know that one of the coolest features it has is, to be able to make a "box selection", so that you can select "columns" of text, just by keeping Ctrl pressed while selecting. Visual studio has now that functionality, as well as the capacity of multi-line editing, which I'm sure you'll find pretty handy!

Alternatives to C sharp and Visual Studio

There are other platforms, libraries, languages and IDE's out there that you can use to build your desktop interfaces/applications, you don't have to limit yourself to Windows platforms or Visual Studio or C#. Below you will find a list of libraries and a list of IDEs and how to use them together.


The GUI libraries are interface designers, usually made up of a set of graphical control elements (widgets). In other words, they are object-oriented widget toolkits written in some programming language. They can sometimes be used with other languages as well, this is done through bindings. Bindings are wrappers for other languages, libraries that translate from one language to another.

If you want to build a GUI for Linux, you have several alternatives. Python and C/C++ are the preferred languages for Ubuntu GUI applications, but there are much more languages you can use. The most used GUI libraries are:

  • GTK

    It supports the standard GTK/GNOME stack of development tools. Although originally GTK+ was developed for the Linux X Window System, it has grown over the years to include back-end support for other well known windowing systems like Windows (32-bit and 64-bit) and Mac OS X. It is written in C but has bindings for many other languages. You can find more about GTK in the Wikipedia or its home page

  • Qt

    Although it started as an application and UI framework for KDE, it is now cross-platform and widely used for developing application software that can be run on various software and hardware platforms with little or no change in the codebase. It's written in C++ or QML, a CSS & JavaScript like language. Qt Creator is the supporting Qt IDE, which has an integrated form designer. You can find more about GTK in the Wikipedia or its home page

  • Glade

    It is a graphical user interface builder/RAD-tool for GTK+, with additional components for GNOME. It is programming language–independent, and has the same list of language bindings as GTK+. The user interfaces designed in Glade are saved as XML, and by using the GtkBuilder GTK+ object these can be loaded by applications dynamically as needed. You can find more about GTK in the Wikipedia or its home page

Althoug GTK and Glade are GNOME oriented and Qt is KDE oriented, you can use Qt apps in Gnome and viceversa with no side effects.


There is a wide offer of IDE's, as one could imagine. Here are the most used:

  • MonoDevelop

    This cross-platform IDE is interesting because it ports Visual Studio applications to Ubuntu, although the process is not perfect.

  • NetBeans

    NetBeans is one of the most comprehensive IDES out there. It has an integrated form designer in the IDE. It's mainly used with Java but you can use it for other languages as well. In Java, the Swing libraries allow you to design GUIs, although JavaFX is intended to replace Swing as the standard GUI library for Java SE. JavaFX is a software platform for creating and delivering rich internet applications (RIAs) that can run across a wide variety of devices.

  • Eclipse

    It is also used with Java, specially for Android application design. The interface designer is integrated in the IDE, and you can use JavaFX or the WindowsBuilder.

  • Anjuta DevStudio

    Anjuta has support for many languages, and supports an integrated interface designer through the installation of Glade. It's only available for Unix-like Operating systems of the GNOME Platform

  • Quickly

    Quickly is a command line application that uses Python. It has no GUI or interface designer, although it can be used with independent interface designers who have a GUI.

Some possible combinations you can use to build your interfaces are:

  • MonoDevelop + GTK# + C, C++, C#.

  • NetBeans + Qt + C++, with the interface designer not integrated into the IDE.

  • NetBeans + Swing/JavaFX + Java, with designer integrated.

  • Eclipse + Swing/JavaFX + Java. Interface designer integrated through the installation of WindowsBuilder.

  • Eclipse + Glade + PyDev, which is a plugin to use Python with Glade. Designer not integrated.

  • Anjuta + GTK+ (designer integrated through the installation of Glade) + C (or C++ with the gtkmm binding). You can use Anjuta with other IDE's, it's independent.

  • Quickly + Glade + Python. Glade is opened as a standalone GUI for the designer.


Have any questions? Spotted any typos? Want to showcase what you did? Found a better solution? Your feedback and suggestions are welcome! And don't forget to share =)