Console App Project Structure
Console applications are the simplest way to start learning and building .NET programs. Let’s walk through the structure of a typical console app and understand how everything fits together.
What is a Console Application?
A console app runs in a terminal or command prompt. It has no GUI, making it ideal for learning programming logic, scripting tasks, and automation tools.
You can create a new console app using Visual Studio or the CLI:
// .NET CLI
dotnet new console -n HelloApp
Default Project Structure
Here’s what you’ll see in a basic console app folder:
Program.cs
– The main file with your entry point (Main
method)HelloApp.csproj
– The project configuration file (XML-based)bin/
andobj/
– Build and intermediate output directories
Example: Program.cs
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
Understanding the .csproj File
This file controls build behavior, dependencies, and targets:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
</Project>
You can also add NuGet packages and references here manually or via CLI.
Build and Run
- In Visual Studio: Press
F5
or click "Start" - In CLI:
dotnet build
dotnet run
When to Use Console Apps
- Learning programming fundamentals (variables, loops, classes)
- Writing utilities, scripts, or automation tools
- Testing libraries or prototypes
Console applications are a perfect way to start building in .NET. They’re fast, simple, and ideal for learning. In the next lesson, you’ll learn how to use namespaces and references to organize and modularize your code better.