Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// 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); } }
Result
Open