-
Notifications
You must be signed in to change notification settings - Fork 2
CSharp Basics Console InputOutput
Joe Care edited this page Dec 22, 2025
·
1 revision
This lesson focuses on getting input from the user and printing output to the console.
Related wiki pages:
- Hello World:
Lesson19.12.2025.md(to be renamed) - Basics:
CSharp-Basics-ConsoleWriteLine-DateTime.md
Official docs:
using System;
namespace CSharpTutorial
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to C# 101!");
Console.Write("Please enter your name: ");
string? userInput = Console.ReadLine();
if (!string.IsNullOrEmpty(userInput))
{
Console.WriteLine("Hello, " + userInput + "!");
}
else
{
Console.WriteLine("You pressed Enter without typing a name.");
}
}
}
}Key APIs:
-
Console.WriteLine– prints text plus newline -
Console.Write– prints text without newline -
Console.ReadLine– reads a full line of input
See the instructions in Lesson19.12.2025.md for creating and running a console project.
- Extend this example to read a number and use
int.TryParse. - Combine with conditions and loops from other lessons in this wiki.