Denis Panjuta
c# basics

C# was developed in the late 1990s after the launch of Java. Both languages have been instrumental in increasing public access to the internet. At that time, the internet was used in universities and businesses for emails and document storage and production. Many things we take for granted today.  

Software companies were starting to develop the concept of internet browsers. These languages were the first steps to exposing the internet to the world.  

Java was launched in 1995 by Sun Microsystems. It was developed with C syntax, was object-oriented and included the concept of virtual environments — the Java virtual machine.

Complete C# Masterclass

Last Updated September 2022

  • 282 lectures
  • All Levels
4.6 (21,808)

Learn C# Programming – WPF, Databases, Linq, Collections, Game Development with Unity. More than just the C# basics! | By Denis Panjuta, by Denis Panjuta

Explore Course

C# was launched in 2000 by Microsoft. It was designed to be a more modern version of C/C++ and has a similar syntax and an object-oriented approach. C# is a type-safe language and memory management is handled by garbage collectors. C# programs are portable in the same way C/C++ programs are. All these characteristics allowed new and experienced programmers to easily learn C#. Systems developed in C/C++ could be translated and modernized with C#.  

C# introduced standardized support for international languages. One of the most critical goals was to develop a language to build web browsers and applications. C# uses Common Language Runtime and the .NET framework, Microsoft’s virtual environment, to do this.

C# was not designed to compete with the size and speed of programs developed with C or lower-level assembly languages.

What is a virtual environment?

Imagine playing Tic-Tac-Toe on your computer. No internet connection or connections to other machines. You and a friend passing the keyboard back and forth taking turns, in the same room side-by-side. No connectivity and no virtual network.

Now connect your computer to another computer on a network — still in the same room. No internet connection. A virtualized version of the same game would allow each machine to share that game. Each machine has the same visuals and uses the mouse and keystrokes from both machines. This is 1980s universities and businesses. Lots of computers connected and hard-wired in local-area networks.

Introduce web programs and virtualization. A web browser allows the program to run on any machine in the world and the game can be developed to allow any number of people to join. The web browser is a virtual environment — unrelated to your PC or the machine the game is running on. It is self-contained.

This was an amazing period in computing history, opening the gateway to developing so many of the ideas and programs we use in our everyday lives.

Program structure and components

A C# program consists of the following components:

Namespace declaration

A namespace is a collection of classes. The program will be one collection. It will use other namespaces from the C# language or those developed by the programmer.

A class

A Class is how objects are defined. Take a car for example. A car is a physical object with attributes such as color, size, weight, and methods such as drive and brake. A class is an object defined with attributes and methods.

Class methods

A method is a block of code that identifies an object’s behavior. If the object is a circle, one behavior might be that it can change size or color.

Class attributes

An attribute is a descriptive characteristic of the class. 

Main method

The main method is the entry point for the class. Executing the class executes this block of code.

Statements and expressions

These are the lines of code in the class methods. All lines end with a semicolon ‘;’.


Text that is not part of the program used to explain what the program is doing. These are optional.

Example program

Let’s look at an example program — we can start with a simple Hello World.

The color of the text is important. When you write your code, you will use an IDE — a program editor — designed for C#. A common example is Visual Studio which is available for free.

            Blue                 C# language component

            Purple              Statements and expressions

            Red                  Comments

            Green              Text used with statements and expressions

Here is the sample program.

using System;
namespace MyHelloWorldApplication {
   class HelloWorld {
      static void Main(string[] args) {
         /* my first program in C# */
         Console.WriteLine("Hello World");

Let’s walk through these lines and understand what they are and how they are used.

Namespace declaration and usage

System — this class contains some of the most fundamental classes and methods used in a program. It is almost universal that all classes use System.

MyHelloWorldApp — the class for this program defined by the programmer. Notice that it has an open curly bracket — there is an associated close curly bracket at the end of the program. These denote the start and end of this namespace.

using System;
namespace MyHelloWorldApp {


This line defines the class — the object processed. Like the Namespace, curly brackets identify the start and end of the class.

class HelloWorld {

Main method

This is the main method of the class executed. Again, note the use of curly brackets.

static void Main(string[] args) {


This is free-form text. This text can help guide a new programmer through the program.

/* my first program in C# */

Statements and expressions

This is a statement intended to write text on the screen. Console is a class in the System Namespace. WriteLine is a Method in that class used to output the text — Hello World — out to the console.

Console.WriteLine("Hello World");

Let’s look at this same program and expand it to include variables and classes. In this case we created a method to output the text to the console. 

As programs get more complex, programmers write methods to execute discrete actions. Imagine the class was a circle — we could write methods to change the color or make it spin. A key component of programming is determining what to put in a method. Code once, execute many times.

Notice the indentation. The indentation makes the program more readable. When to use blank lines? Does each class have a comment at the top describing the class? Programming teams will start with identifying standards. When team members use the same standards, it is easy to support one another.

using System;
namespace MyHelloWorldApplication {
   class HelloWorld {
      static void Main(string[] args) {
         /* variable with text to output */
         string HelloText = "Hello World";
         WriteTextMethod("I am your friend!");
      public void WriteTextMethod(string myString) {

This is a basic introduction to the world of C# programming. The language includes an amazing set of tools. C# is used to build desktop applications that run on Windows PCs and web applications and services. A real-time development platform called Unity allows C# applications to run on MACs. Unity is a host to an array of exciting and advanced applications including games and virtual reality experiences.

Top courses in C#

Complete C# Unity Game Developer 3D
Ben Tristem, Rick Davidson, Team, Gary Pettie
4.8 (35,986)
C# Intermediate: Classes, Interfaces and OOP
Mosh Hamedani
4.5 (30,139)
Learn Parallel Programming with C# and .NET
Dmitri Nesteruk
4.5 (2,969)
RPG Core Combat Creator: Learn Intermediate Unity C# Coding
Ben Tristem, Rick Davidson, Sam Pattuzzi, Team
4.8 (10,077)
Complete C# Masterclass
Denis Panjuta, by Denis Panjuta
4.6 (21,809)
Unity RPG Inventory Systems Asset Pack: Behind The Scenes
Sam Pattuzzi, Team, Rick Davidson
4.4 (706)

More C# Courses

C# students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy Business.

Request a demo

Courses by Denis Panjuta

Der Unity 2017 & Blender Komplettkurs: Erstelle Top 3D Games
Denis Panjuta, Jannick Leismann, by Denis Panjuta
4.1 (509)
Highest Rated
Online Course Creation Masterclass - Udemy - Unofficial
Denis Panjuta, by Denis Panjuta
4.4 (20)
Complete C# Unity Developer: Create Games and Learn to Code
Denis Panjuta, by Denis Panjuta
4.9 (970)
Xamarin Forms: Erstelle Native Cross Plattform Apps mit C#
Denis Panjuta, by Denis Panjuta
4.7 (365)
Erstelle iOS Apps die geliebt werden
Codestars • over 2 million students worldwide!, Denis Panjuta, Rob Percival, by Denis Panjuta
3.7 (748)
Erstelle einen 3D Jump and Run Plattformer mit Unity 3D
Denis Panjuta, by Denis Panjuta
4.5 (43)
Lerne großartige Webseiten zu erstellen
Jan Brinkmann, Denis Panjuta, Jannis Seemann, by Denis Panjuta
4.5 (774)
Der ultimative Wordpress Kurs- dein Weg zur eigenen Webseite
Denis Panjuta, by Denis Panjuta
4.6 (34)
JavaScript und jQuery für Beginner
Denis Panjuta, by Denis Panjuta
3.5 (156)
Erstelle Android Apps, die geliebt werden!
Denis Panjuta, Codestars • over 2 million students worldwide!, by Denis Panjuta
3.6 (910)
Online Geld verdienen - Lebensunterhalt mit Videokursen
Denis Panjuta, by Denis Panjuta
4 (163)
Der Komplette Web-Entwickler Kurs - Erstelle 14 Webseiten
Denis Panjuta, Codestars • over 2 million students worldwide!, by Denis Panjuta
3.6 (695)

Courses by Denis Panjuta