Posts

Showing posts with the label C# (C Sharp)

React State Tutorial: Build a Course Filter

Web Development Learning Series — Part 6 of 10 · Intermediate to Advanced React is useful when a page has several connected interactive views. The challenge is often deciding what the application needs to remember. This lesson builds a difficulty filter for a course catalog and keeps the state small. Use an existing React learning project or the official documentation's interactive editor. This example is a component, not a complete installation guide. You should already know JavaScript arrays, functions, and basic JSX.

C# Hello World: Create and Run Your First Console Program

Image
Write and run your first C# console program. This lesson includes the commands, complete code, expected output, and fixes for common beginner errors. Before you start Install the .NET SDK from Microsoft's official website. An editor alone cannot compile C#. Open a terminal and run dotnet --version . A version number confirms that the command is available. Create a console project dotnet new console -n HelloCourse cd HelloCourse dotnet run The template creates a project file and Program.cs. Run the commands one line at a time. The final command builds and runs the project in the current directory. A complete program with Main Replace the contents of Program.cs with this code. Use this version if your course explains classes and the Main entry point. using System; class Program { static void Main() { Console.WriteLine("Hello, World!"); } } Save the file and run dotnet run again. Expected output: Hello, World! using System lets us use Console without w...

C# Methods: Parameters, Calls and Return Values

Image
A C# method groups statements under a name so you can call them again. This lesson builds a console program that displays two course messages and calculates a total. Start with our C# Hello World setup guide if you have not created a console project. Complete method-calling example Replace Program.cs in a console project with the code below, save it, and run dotnet run from the project directory. using System; class Program { static void Main() { ShowMessage("Welcome to C#"); ShowMessage("Practice one method at a time"); int total = AddLessons(3, 2); Console.WriteLine($"Total lessons: {total}"); } static void ShowMessage(string message) { Console.WriteLine(message); } static int AddLessons(int completed, int planned) { return completed + planned; } } Expected output Welcome to C# Practice one method at a time Total lessons: 5 Main runs first. It calls ShowMessage with ...