Hello, .NET
Part of the C# and .NET Basics section of Coddy's ASP.NET Core journey. Lesson 1 of 20.
.NET is the platform C# runs on. It has two parts: the runtime, which runs compiled programs, and the SDK, the tools that build them. On your own computer, dotnet new console makes a project and dotnet run builds and runs it. A project file, .csproj, tells the SDK what to build. Here Coddy keeps that file for you.
A modern C# program needs no class and no Main method. The lines at the top of Program.cs are top-level statements, and they run in order:
Console.WriteLine("Weather Station");
Console.WriteLine("Sunny, 24 degrees");Each Console.WriteLine prints one line. Press Run to build the program and see what it prints.
Challenge
BeginnerIn this section you build an expense tracker you run from the command line. It starts with its title and how many expenses it holds.
- In
Program.cs, replace the line that printsHello, .NET!. - The program must print exactly these two lines, in this order, and nothing else:
Expense Tracker 0 expensesExpense Trackerhas a capital E and a capital T.0 expensesis all lowercase.
Try it: press Run. The output shows the two lines above, with nothing before them.
Try it yourself
Console.WriteLine("Hello, .NET!");