Hello World - potatoscript/csharp GitHub Wiki
👋 Hello World! 👋
Welcome to the first step in your C# programming journey! To get started, we’ll create a program that makes the computer say "Hello, World!". This is a special program that every beginner writes as their very first program in any programming language. It’s like introducing yourself to the world of coding! 🌍
Let’s imagine that Cody (our robot friend) is really shy and doesn’t know how to talk to people. But we want Cody to introduce himself to the world by saying “Hello, World!” in a way that everyone can understand. That’s exactly what we’re going to do!
🧑💻 What is the "Hello, World!" Program? 🧑💻
A "Hello, World!" program is the simplest program you can write in any programming language. It does one thing only: print the message “Hello, World!” on the screen. It’s like pressing a button to make Cody speak his first words. 🎤
🚀 Let’s Write Our First Program 🚀
Ready? Let’s help Cody speak his first words in C#! Follow the steps below to write and run your first C# program:
-
Open Visual Studio 📀
- This is the tool where we write and run our C# code. Open Visual Studio, which we installed earlier.
-
Create a New Project 🆕
- After opening Visual Studio, click on "Create a new project".
- In the search bar, type "Console App". This is the type of project we need to create a simple text-based program.
- Select "Console App" from the list and click Next.
-
Name Your Project 🏷️
- Give your project a name. Let’s call it "CodyHelloWorld" so we know it’s Cody’s first program!
- Click Create.
📝 Here’s the Code to Say "Hello, World!" 📝
Now, let's write the code that tells Cody to speak! In the new window that appears, you’ll see some code already written. Replace everything inside with this code:
using System; // This is like telling the program "Hey, let's use the tools we need!"
class Program // This is where we give Cody his instructions.
{
static void Main() // This is where Cody starts working.
{
Console.WriteLine("Hello, World!"); // This tells Cody to say "Hello, World!" on the screen.
}
}
🧑💻 Explanation of the Code 🧑💻
Let’s go over this code and understand what each part means, step by step:
-
using System;
🛠️- This line tells Visual Studio: “We want to use System tools!” The System toolbox is like Cody’s toolkit. It helps Cody talk to the screen, among other things.
-
class Program
📦- This is like saying: “Here is where we write all of Cody’s instructions!” The class is a container that holds everything Cody needs to do.
-
static void Main()
🏁- This is where Cody starts working. When you run your program, it always starts at Main. It’s like Cody’s starting point. All programs have this special place to begin.
-
Console.WriteLine("Hello, World!");
🎤- This is where Cody speaks! It tells the program to show the text "Hello, World!" on the screen.
Console.WriteLine
is like Cody’s voice that can say anything you tell it.
- This is where Cody speaks! It tells the program to show the text "Hello, World!" on the screen.
🏁 Run the Program and Meet Cody 🎬
Now, let’s get Cody to speak! To see Cody’s first words, we need to run the program.
-
Click the Green Play Button ▶️
- At the top of Visual Studio, there is a green play button. This button tells Visual Studio to run the program.
- Click on it, and Cody will start talking!
-
See Cody Speak 🎤
- A new window will appear showing “Hello, World!”. This is Cody’s first message to the world! 🌍
- Cody says “Hello, World!” on the screen for everyone to see.