C# Basics
Print a value from a .NET program.
C#
using System;
class Program {
static void Main() {
string name = "Ada";
Console.WriteLine($"Hello, {name}");
}
}Output
Hello, Ada
Explanation
Execution starts in Main. Console.WriteLine writes a line to standard output. The using directive makes System types available by short name.
Explore the dry run
Guided walkthroughReady
1
using System;2
class Program {3
static void Main() {4
string name = "Ada";5
Console.WriteLine($"Hello, {name}");6
}7
}Follow the example
Start to inspect the source, values, and output. These prepared steps explain the published sample; grouped loop steps describe multiple iterations.
View the complete dry-run table
| Step / line | What happens | State after step | Output so far |
|---|---|---|---|
| Create a string variable. | name = "Ada" | — | |
| Interpolate name and write the resulting line. | name = "Ada" | Hello, Ada |