C#
Beginner
1 min read
What Is C# and the .NET Platform
Example
// HelloWorld.cs — a minimal .NET 8 console application
// With top-level statements there is no need for a class or Main method.
using System;
Console.WriteLine("Hello, .NET 8!");
// Variables use type inference with 'var'
var language = "C#";
var version = 12;
Console.WriteLine($"Language: {language}, Version: {version}");
// String interpolation embeds expressions directly in string literals
string name = "World";
Console.WriteLine($"Hello, {name}!");
// Verbatim strings preserve backslashes and newlines
string path = @"C:\Users\Alice\Documents";
Console.WriteLine(path);
// Raw string literals (C# 11+) need no escaping at all
string json = """
{
"key": "value"
}
""";
Console.WriteLine(json);
// The Environment class exposes runtime information
Console.WriteLine($".NET version: {Environment.Version}");
Console.WriteLine($"OS: {Environment.OSVersion}");