05 November 2026

.NET Core for Students: Setup, C# Basics and Your First Program

  Asp.Net CS By Example       05 November 2026

Student learning series · Lesson 1 of 6

Understand .NET, install an SDK, and write a C# console program with arrays and LINQ.

What you will learn

The SDK builds applications; the runtime executes them. C# is a language, .NET is the platform, and ASP.NET Core is the web framework. .NET Core was renamed .NET from version 5 onward. ASP.NET Core keeps its name. Classic ASP.NET Web Forms uses .NET Framework and does not run unchanged on ASP.NET Core.

1. Create the project

dotnet new console -n CoreConsole
cd CoreConsole

Run dotnet --info first. Install a currently supported SDK from Microsoft if the command is missing. Replace Program.cs with the complete example below. The collection expression syntax requires C# 12 or later; use a current supported SDK. This example was compiled with SDK 9.0.306.

2. Complete Program.cs

using System;
using System.Linq;

int[] marks = [42, 78, 90];
double average = marks.Average();
int passed = marks.Count(mark => mark >= 60);
Console.WriteLine($"Students: {marks.Length}");
Console.WriteLine($"Average: {average:F1}");
Console.WriteLine($"Passed: {passed}");

3. Run and observe

dotnet run

Stop the server with Ctrl+C before starting the next lesson on the same port. For web lessons, visit the listed GET path at http://127.0.0.1:5070 in your browser. Use an HTTP client for POST, PUT and DELETE with Content-Type: application/json.

Students: 3
Average: 70.0
Passed: 2

4. Understand the code

An array stores the three integer marks. Average calculates their mean; Count receives a lambda that selects passing marks. The dollar sign enables interpolation and F1 displays one decimal place. Top-level statements remove the need to write an explicit Main method.

Practice exercise

Change the pass mark to 75 and add a fourth mark of 100. Calculate the new average before running.

Self-check and answer

The four marks total 310, so the average is 77.5 and three students pass at 75. The SDK is required to build; a runtime alone is insufficient.

Study notes

Type the example yourself, run it, change one behavior, and explain the result in your own words. Keep each lesson in its own project. These examples were compiled with .NET SDK 9.0.306; select a currently supported SDK for new study projects. The course teaches modern .NET and ASP.NET Core, rather than obsolete .NET Core 3.1 or classic Web Forms.

Return to the .NET Core student learning path · Official Microsoft documentation · .NET support policy

logoblog

Thanks for reading .NET Core for Students: Setup, C# Basics and Your First Program

Previous
« Prev Post

No comments:

Post a Comment

Please do not enter any spam link in the comment box.