What is C#?
C# (pronounced "C-sharp") is a modern, object-oriented programming language developed by Microsoft. It was created by Anders Hejlsberg and released in 2000 as part of the .NET initiative.
Key Features:
- Type Safe: Strong typing prevents many bugs
- Modern Syntax: Clean, expressive, constantly evolving
- Cross-Platform: .NET Core runs on Windows, Mac, Linux
- Garbage Collected: Automatic memory management
- Rich Ecosystem: Extensive standard library
Where C# is Used:
- Game Development (Unity)
- Web Applications (ASP.NET)
- Desktop Apps (WPF, WinForms, MAUI)
- Cloud Services (Azure)
- Mobile Apps (Xamarin, MAUI)
C# Versions: C# evolves quickly. C# 12 is the latest, with features like primary constructors and collection expressions.
Code Examples
Hello Worldcsharp
// Modern C# (top-level statements)
Console.WriteLine("Hello, World!");
// Variables with type inference
var name = "C#";
var version = 12;
Console.WriteLine($"Welcome to {name} {version}!");
// Traditional class structure
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello from Main!");
// String interpolation
string language = "C#";
int year = 2024;
Console.WriteLine($"{language} in {year} is amazing!");
}
}Modern C# supports top-level statements for simple programs. The $ prefix enables string interpolation.
Quick Quiz
1. Who created C#?
Was this lesson helpful?