Appearance
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#?
| Feature | Description |
|---|---|
| Versatile | Build web, desktop, mobile, games, and cloud applications |
| Type-Safe | Catch errors at compile time with strong typing |
| Modern Syntax | Clean, readable code with powerful features |
| Enterprise Ready | Battle-tested in large-scale applications |
| Cross-Platform | Run on Windows, macOS, Linux, and more |
| Game Development | Primary language for Unity game engine |
What You'll Learn
Beginner
- Getting Started - Setup and first program
- Variables & Types - Data types and variables
- Control Flow - Conditions and loops
Intermediate
- Methods - Functions and parameters
- Classes & Objects - Object-oriented basics
- Inheritance - Code reuse and polymorphism
Advanced
- Interfaces - Contracts and abstraction
- Generics - Type-safe reusable code
- LINQ - Language Integrated Query
- Async Programming - Asynchronous patterns
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.8bash
# Using Homebrew:
brew install dotnet-sdk
# Or download from https://dotnet.microsoft.com/downloadbash
# Ubuntu/Debian:
sudo apt-get update
sudo apt-get install -y dotnet-sdk-8.0
# Fedora:
sudo dnf install dotnet-sdk-8.0Verify Installation
bash
dotnet --versionCreate Your First Project
bash
# Create a new console application
dotnet new console -n MyFirstApp
# Navigate to project folder
cd MyFirstApp
# Run the application
dotnet runProject Structure
MyFirstApp/
├── MyFirstApp.csproj # Project configuration
├── Program.cs # Main entry point
├── obj/ # Build objects
└── bin/ # Compiled outputRecommended IDEs
| IDE | Description |
|---|---|
| Visual Studio | Full-featured IDE (Windows/Mac) |
| VS Code | Lightweight editor with C# extension |
| JetBrains Rider | Cross-platform professional IDE |
Video Tutorials
Recommended Video Resources
Learn C# through these excellent tutorials.
Free Courses
| Course | Creator | Description |
|---|---|---|
| C# Fundamentals | freeCodeCamp | Complete C# course for beginners |
| C# Tutorial | Bro Code | Full C# programming tutorial |
| C# Full Course | Caleb Curry | Comprehensive C# tutorial |
Let's Begin!
Ready to start? Head over to Getting Started to write your first C# program!