Write Console.WriteLine Hello World
Context: Console.WriteLine() writes a line to the console. This is the most basic output method in .NET 10.
Console.WriteLine() writes a line of text to the console output.
Basic Usage
Section titled “Basic Usage”Open Program.cs and write:
Console.WriteLine("Hello World");Multiple Lines
Section titled “Multiple Lines”Console.WriteLine("Hello");Console.WriteLine("World");Console.WriteLine("From .NET!");Write Without Newline
Section titled “Write Without Newline”Console.Write("Hello ");Console.Write("World");// Output: "Hello World"String Interpolation
Section titled “String Interpolation”string name = "Alice";Console.WriteLine($"Hello {name}");// Output: Hello AliceFormatting
Section titled “Formatting”int number = 42;Console.WriteLine($"Number: {number,10}"); // Right-alignedConsole.WriteLine($"Number: {number,-10}"); // Left-aligned