What is C#?
C# (pronounced "C sharp") is a modern, object-oriented, and type-safe programming language developed by Microsoft as part of the .NET platform. It was designed by Anders Hejlsberg and released in 2000. C# is heavily influenced by Java and C++.
Key Features
- Strongly Typed — every variable has a declared type checked at compile time
- Object-Oriented — classes, interfaces, inheritance, polymorphism
- Cross-Platform — .NET runs on Windows, Linux, and macOS
- Modern Syntax — LINQ, async/await, records, pattern matching, nullable types
- Garbage Collected — no manual memory management needed
Your First C# Program
// Program.cs
using System;
class Program {
static void Main(string[] args) {
Console.WriteLine("Hello, World!");
}
}
Top-Level Statements (C# 9+)
// No class/Main boilerplate needed in C# 9+
Console.WriteLine("Hello, World!");
Compiling and Running
dotnet new console -n MyApp
cd MyApp
dotnet run
Where C# is Used
- 🎮 Game development with Unity (most popular game engine)
- 🌐 Web APIs and microservices with ASP.NET Core
- 🖥️ Desktop apps with WPF and WinForms
- 📱 Mobile apps with .NET MAUI / Xamarin
- ☁️ Cloud services on Azure