C# (.NET 8 LTS) track

Lesson 01 · Part 1: Basics

Getting Started with C#

Set up the .NET SDK and tooling, then build and run your first C# console application.

Part 1: Basics3 min readFree lesson

C# is a statically typed language created by Microsoft and is widely used in games (Unity), web (ASP.NET), desktop, and mobile. In this section, you will install the .NET 8 SDK, create a console project, and run it directly.

Learning Objectives

  • Know the meaning of .NET 8 LTS and the difference between SDK/Runtime
  • Choose one of the IDEs (Visual Studio / VS Code / Rider) and install it.
  • Create your first project with dotnet new console
  • Run with dotnet run and check the results.
  • Perform simple input/output with Console.WriteLine / Console.ReadLine

Key concepts

1) What is .NET?

.NET is a bundle of runtime + standard library + SDK that runs languages such as C#, F#, and VB.NET. Code written once can be run in all On-Windows/macOS/Linux.

  • .NET 8 LTS: Long Term Support version released in November 2023. Official support until November 2026.
  • SDK: Compiler and tool set required for development (including dotnet CLI)
  • Runtime: Minimum components required to simply run the created program.

2) Check SDK installation

After installation, check with the command below in terminal.

dotnet --version
#Example output: 8.0.xxx

If you start with 8.0, it's OK. If there is no command, download and install .NET 8 SDK from https://dotnet.microsoft.com/download.

3) Select IDE

  • Visual Studio 2022 (Windows) — Heavy but most integrated environment
  • VS Code + C# Dev Kit (cross platform) — Light and fast, recommended
  • JetBrains Rider — Paid but powerful refactoring

This course is IDE agnostic. Either way, the operation is the same with dotnet CLI.

4) Create your first project

dotnet new console -o HelloApp
cd HelloApp
dotnet run
  • dotnet new console: Create console app template
  • -o HelloApp: Created in HelloApp folder
  • dotnet run: Build (restore automatically if necessary) → Run

When running for the first time, Hello, World! is output.

5) Top-level statements

Since .NET 6, you can skip the Main method and write your code straight away.

// Program.cs
Console.WriteLine("Hello!");

Console.WriteLine outputs with line breaks, and Console.Write outputs without line breaks.

See as example

Example 1 — HelloApp/Program.cs: The most basic

//First C# program
Console.WriteLine("Hello, C# !");

Execution result

Hello, C# !

Note: Don't forget the semicolon (;). C# separates sentences with ;, not line breaks.

Example 2 — Echo/Program.cs: Accept input and say hello

Console.Write("Please enter your name:");
string? name = Console.ReadLine();
Console.WriteLine($"Hello {name}!");

Execution result

Enter your name: Jisoo
Hello, Jisoo!

Memo: Console.ReadLine() can return null if there is no input, so the type is string?. (More details in section 2)

Example 3 — MultiPrint/Program.cs: Multiple lines + string interpolation

string product = "apple";
int count = 3;
int price = 1500;

Console.WriteLine("=== Purchase History ===");
Console.WriteLine($"Product: {product}");
Console.WriteLine($"Quantity: {count}");
Console.WriteLine($"Total: {count * price} won");

Execution result

=== Purchase History ===
Product: Apples
Quantity: 3
Total: 4,500 won

Memo: { } within $"..." can be entered as an expression. This is called string interpolation.

Common Mistakes

  1. Case is incorrect, like Console.Writeline — C# is case sensitive.
  2. Missing ; at the end of the sentence — compilation error.
  3. Using only "{name}" without $, {name} is output as is.
  4. When running dotnet run outside the project folder, a “project not found” error occurs.
  5. Confusing .NET Framework 4.x and .NET 8 — This tutorial is based on .NET 8 (Core series).

Cleanup

  • After installing .NET 8 SDK, check with dotnet --version
  • dotnet new console -o name → dotnet run is the basic flow.
  • Output as Console.WriteLine, input as Console.ReadLine
  • $"..." string interpolation neatly inserts variables

Try it yourself

cd src/HelloApp
dotnet run

cd ../Echo
dotnet run

cd ../MultiPrint
dotnet run

Example files

The runnable files used in this lesson. Copy them into your own project and experiment.

src/Echo/Echo.csprojText
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <RootNamespace>CodingNow.Lecture.Basics01</RootNamespace>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>
src/Echo/Program.csC#
//Take your username and say hello
Console.Write("Please enter your name:");
string? name = Console.ReadLine();
Console.WriteLine($"Hello {name}!");
src/HelloApp/HelloApp.csprojText
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <RootNamespace>CodingNow.Lecture.Basics01</RootNamespace>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>
src/HelloApp/Program.csC#
//First C# program
Console.WriteLine("Hello, C# !");
src/MultiPrint/MultiPrint.csprojText
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <RootNamespace>CodingNow.Lecture.Basics01</RootNamespace>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>
src/MultiPrint/Program.csC#
//Multi-line output + string interpolation
string product = "apple";
int count = 3;
int price = 1500;

Console.WriteLine("=== Purchase History ===");
Console.WriteLine($"Product: {product}");
Console.WriteLine($"Quantity: {count}");
Console.WriteLine($"Total: {count * price} won");

Assignment

Problem 1 — Self-introduction printer

  • Reference solution: shown below
  • Key concepts: Console.WriteLine, string interpolation

Requirements

  • Declare three variables: name, age, and city of residence.
  • Output in the following format:

Hello! My name is OOO, and I am OO years old. I live in OO.


### Expected output

Hello! My name is Jisoo, and I am 25 years old. I live in Seoul.


### Hint
- Variables are declared as `string name = "exponent";`
- Utilizes string interpolation `$"My name is {name}..."`

## Problem 2 — Greetings with current time
- Reference solution: shown below
- Key concepts: `DateTime.Now`, string interpolation

### Requirements
- Enter a name from the user
- Prints the current time together (using `DateTime.Now`)

### Expected output

Name: Minsu Minsu, hello! The current time is 2025-05-18 14:30:00.


### Hint
- The visual format can be used like `$"{DateTime.Now:yyyy-MM-dd HH:mm:ss}"`
- The return type of `Console.ReadLine()` is `string?`

## Check the correct answer
After solving it yourself, compare it with the reference solution below.
Show the reference solution

Try the assignment yourself first — comparing your attempt with a working solution is where most of the learning happens.

Homework01/Homework01.csprojText
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <RootNamespace>CodingNow.Lecture.Basics01</RootNamespace>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>
Homework01/Program.csC#
//self-introduction printer
string name = "exponent";
int age = 25;
string city = "Seoul";

Console.WriteLine("Hello!");
Console.WriteLine($"My name is {name} and I am {age} years old.");
Console.WriteLine($"I live in {city}.");
Homework02/Homework02.csprojText
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <RootNamespace>CodingNow.Lecture.Basics01</RootNamespace>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>
Homework02/Program.csC#
//Greetings with current time
Console.Write("Name:");
string? name = Console.ReadLine();

Console.WriteLine($"Hello {name}!");
Console.WriteLine($"The current time is {DateTime.Now:yyyy-MM-dd HH:mm:ss}.");

Learn this lesson with a mentor

Work through the C# (.NET 8 LTS) track on your own, or join a guided cohort at our Pitampura campus and online.

Call NowEnroll Now