Skip to content

C# Tutorial

Official Documentation

This tutorial is based on official Microsoft C# documentation. Visit: C# Documentation

Welcome to the C# tutorial! C# (pronounced "C-sharp") is a modern, object-oriented programming language developed by Microsoft.

What is C#?

┌─────────────────────────────────────────────────────────────┐
│                         C# Language                         │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────┐  │
│  │   Type      │  │   Object-   │  │    Modern           │  │
│  │   Safety    │  │   Oriented  │  │    Features         │  │
│  └─────────────┘  └─────────────┘  └─────────────────────┘  │
├─────────────────────────────────────────────────────────────┤
│                    .NET Runtime (CLR)                       │
├─────────────────────────────────────────────────────────────┤
│  Windows  │  macOS  │  Linux  │  iOS  │  Android  │  Web   │
└─────────────────────────────────────────────────────────────┘

Why Learn C#?

FeatureDescription
VersatileBuild web, desktop, mobile, games, and cloud applications
Type-SafeCatch errors at compile time with strong typing
Modern SyntaxClean, readable code with powerful features
Enterprise ReadyBattle-tested in large-scale applications
Cross-PlatformRun on Windows, macOS, Linux, and more
Game DevelopmentPrimary language for Unity game engine

What You'll Learn

Beginner

Intermediate

Advanced

Prerequisites

  • ✅ Basic programming concepts
  • ✅ Understanding of variables and functions
  • ⭐ Optional: Experience with any C-style language

Quick Preview

csharp
using System;

// Hello World in C#
class Program
{
    static void Main()
    {
        Console.WriteLine("Hello, World!");

        // Variables and types
        string name = "Developer";
        int age = 25;
        bool isLearning = true;

        // String interpolation
        Console.WriteLine($"Hi {name}, you are {age} years old!");

        // Collections
        var languages = new List<string> { "C#", "Python", "JavaScript" };

        foreach (var lang in languages)
        {
            Console.WriteLine($"I know {lang}");
        }
    }
}

Setting Up Your Environment

Install .NET SDK

bash
# Download from https://dotnet.microsoft.com/download
# Or use winget:
winget install Microsoft.DotNet.SDK.8
bash
# Using Homebrew:
brew install dotnet-sdk

# Or download from https://dotnet.microsoft.com/download
bash
# Ubuntu/Debian:
sudo apt-get update
sudo apt-get install -y dotnet-sdk-8.0

# Fedora:
sudo dnf install dotnet-sdk-8.0

Verify Installation

bash
dotnet --version

Create Your First Project

bash
# Create a new console application
dotnet new console -n MyFirstApp

# Navigate to project folder
cd MyFirstApp

# Run the application
dotnet run

Project Structure

MyFirstApp/
├── MyFirstApp.csproj    # Project configuration
├── Program.cs           # Main entry point
├── obj/                 # Build objects
└── bin/                 # Compiled output
IDEDescription
Visual StudioFull-featured IDE (Windows/Mac)
VS CodeLightweight editor with C# extension
JetBrains RiderCross-platform professional IDE

Video Tutorials

Recommended Video Resources

Learn C# through these excellent tutorials.

Free Courses

CourseCreatorDescription
C# FundamentalsfreeCodeCampComplete C# course for beginners
C# TutorialBro CodeFull C# programming tutorial
C# Full CourseCaleb CurryComprehensive C# tutorial

Let's Begin!

Ready to start? Head over to Getting Started to write your first C# program!