Console.WriteLine()
Console.WriteLine() is C#'s method for printing a line of text to the console (terminal). It writes whatever you pass it and then moves to a new line.
C#
It lives in the System namespace and is one of the first things you learn in C#. Use Console.Write() instead if you don't want the trailing newline.
You can insert variables into the text using string interpolation with a $ before the string, which is the modern, readable way to format output.
Syntax
Console.WriteLine(value);Examples
C#
Console.WriteLine("Hello, world!");Output:
Hello, world!C#
string name = "Sam";
int age = 20;
Console.WriteLine($"{name} is {age}");Output:
Sam is 20