Console project anatomy
A project groups source files and build settings into one application. In a simple C# console project, Program.cs contains instructions and the .csproj file describes how to build them. A .csproj is XML, a structured text format with matching opening and closing tags. You can learn this layout without installing extra packages.
Create an isolated console project
In an approved empty workspace, use the console template to generate a starter project. The explicit --no-restore option prevents template creation from immediately restoring dependencies. Use the pinned SDK from the preceding lesson and confirm the destination does not already contain valuable files.
Read the project file
Sdk selects the project build SDK. OutputType is Exe for this executable project. TargetFramework uses net10.0, which selects the .NET 10 compile-time framework contract. LangVersion explicitly selects C# 14 for the fixture; the normal SDK default is compatible with the target framework. Nullable enables null analysis (covered later). ImplicitUsings controls automatically provided namespace imports. We disable it here and write fully qualified names, so examples show where library names come from.
Source versus generated files
Program.cs and the project file are author-maintained inputs. After restore and build, obj contains intermediate material such as dependency information; bin contains build artifacts. Do not edit generated files to change the program. A solution is a container for organizing projects; a single console project does not require one. Both traditional .sln and newer .slnx solution formats exist; use the format supported by the selected SDK and tools.
Examples and walkthroughs
dotnet new console --name ShelfCounter --output ShelfCounter --framework net10.0 --no-restoreExpected result: a new directory ShelfCounter with a project file and source file. Template output varies. Do not run this in an existing project or add --force.
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net10.0</TargetFramework> <LangVersion>14.0</LangVersion> <Nullable>enable</Nullable> <ImplicitUsings>disable</ImplicitUsings> </PropertyGroup></Project>Use as ShelfCounter.csproj in the isolated fixture, replacing the generated project file only in that fresh lab.
The full name System.Console avoids reliance on implicit usings. The program writes one line.
Expected output (reasoned, not executed):
Shelf counter ready.Common mistake and correction
Changing the DLL in bin or the generated project assets in obj is not the normal way to change source. Edit Program.cs or the project file, then rebuild. Installing a newer SDK does not automatically change net10.0 to another target.
Try it yourself
Draw a three-column map of Program.cs, ShelfCounter.csproj, bin and obj: source, configuration or generated output. Then change the message in the reviewed fixture to "Returns counter ready."
Next: Build, run and publish. These examples are static study material; actual C# compilation and ByteMind execution have not been verified.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Console project anatomy — knowledge check
Apply the lesson concepts to the following scenarios.
Which file sets the target framework?
Which file should you edit to change a printed greeting?
What is the effect of --no-restore when creating the console project?
ImplicitUsings is disabled. Which instruction remains valid without a using directive?
Which claim about a solution is correct for a single console app?