C# (pronounced "C Sharp") is a modern, object-oriented programming language developed by Microsoft as part of the .NET platform. It is used to build Windows applications, web services with ASP.NET, games with Unity, and mobile apps with Xamarin.
C#
Beginner
8 min read
Introduction to C#
Example
// HelloWorld.cs
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
Console.WriteLine("Hello, C#!");
// Variables (type inferred with var)
var name = "Alice";
var age = 30;
var pi = 3.14159;
// String interpolation
Console.WriteLine($"Name: {name}, Age: {age}");
// List and LINQ
var numbers = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var evens = numbers.Where(n => n % 2 == 0).ToList();
Console.WriteLine(string.Join(", ", evens));
// Null coalescing
string? nullable = null;
string result = nullable ?? "default";
Console.WriteLine(result);
}
}