C# Examples

A comprehensive list of C# examples.

C# Examples

Learn by examples! This page lists all the C# examples available in this tutorial.

We believe that the best way to learn programming is by practice.

  • Basics: Hello World, Comments, Variables
  • Control Flow: If/Else, Loops, Switch
  • Methods: Functions, Parameters, Overloading
  • OOP: Classes, Objects, Inheritance, Polymorphism
  • Files: Read, Write, Delete

Use the "Try it Yourself" editor to experiment with the code.

Examples

Hello World

The classic first example.

using System;

class Program
{
  static void Main(string[] args)
  {
    Console.WriteLine("Hello World!");
  }
}