Welcome to the C# tutorial.

If you get any problems when using C#, you can ask a question or study one of the additional materials.

Computer programs consist of many machine instructions. Nobody has time to write machine instructions, so programming languages have been designed. One of these languages is C#.

Quick Start

Create the hello world app

We create a C# program that outputs “Hello, World” to the screen.
Copy the code below and save the file as hello.cs

1
2
3
4
5
6
7
8
9
10
11
using System;

namespace HelloWorldApplication {
class HelloWorld {
static void Main(string[] args) {
/* First C# program */
Console.WriteLine("Hello, World");
Console.ReadKey();
}
}
}

This outputs:

Hello, World

To make C# programs you need Visual Studio Code or Microsoft Visual Studio C#.

How it works

The program defines the function Main, which starts at the character { and ends at character }.

Its then followed by a single line comment, this is a text that’s ignored by the compiler.

A line of text is written to the screen with the line Console.WriteLine("Hello, World");.

The program then waits for keyboard input Console.ReadKey();.

Exercises

  1. Create a program that outputs your name
  2. Create a program that outputs your address (multiple lines).