Loading...

C# Introduction

Open a tiny C# file and predict the one word it writes on the screen. In Pine.cs, keep a public class named Pine, keep a Main method, and call Console.WriteLine("pine");. When the file runs, the screen shows pine. The quotes stay in the file. The class name Pine stays off the screen. Leave installing the .NET SDK and the run commands for the next page. This lesson is the first file and its screen line, not an ASP.NET site and not a Unity scene.

One file, one screen word

C# is a language for programs you save in a file and run from a terminal on .NET. The terminal is the window where you type a command and read the lines it writes back. This course stays with those console files. You write a file, run it, and read the screen. You are not building a web page on this page. You are not opening a game editor on this page.
Name the teaching file Pine.cs. Keep the public class name Pine so the class and the file stem match for this beginner shape. Inside Main, write one word to the screen:
Console.WriteLine("pine");
That call is the writing line. The word between the quotes is pine. When the program runs, that word is what the screen shows. Keep the quotes in the file so C# treats pine as text. Do not invent a second print on this page. One clear screen word is enough for the introduction.

Pine.cs writes pine

csharp
using System;

public class Pine
{
    public static void Main()
    {
        Console.WriteLine("pine");
    }
}

Walk the file once with your eyes. The first useful lines bring in System with using System; so short names like Console work. public class Pine names the type. public static void Main() marks the entry the runtime starts. Console.WriteLine("pine"); writes the screen line. When this file runs, the screen shows pine. There is no second line. Nothing sits beside pine on that line.
Say the beginner rule while you look at the writing line: the screen uses the word between the quotes, not the class name on the type line. Pine with a capital P is the class. pine with a small p is the screen word. Those are not the same token. If you still hear mint from a leftover Java introduction demo, leave that as another course and keep pine here.

Class name is not the screen

The first type line is public class Pine. Look at the screen again after a run. The screen does not show Pine. It shows pine. The capital letter and the small letter mark different words. Beginners often point at the class name and guess the screen will match it. On this page that guess fails. The writing line decides the screen. The writing line is Console.WriteLine("pine");.
Other lines in the file matter later. using System; prepares short names. Main is the entry. Braces group the method body. Those lines are part of the program. They are not copied onto the screen as text. A later page reads install and run commands. On this page you are responsible for naming the screen word and the writing line that produces it.

File habits for the first program

Keep file name, class name, writing line, and screen word easy to tell apart.

📊 First C# file habits for Pine

Habit Shape Beginner check
File Pine.cs ends with .cs
Class public class Pine matches the file stem on this page
Entry Main runtime starts here
Writing line Console.WriteLine("pine"); quotes mark the text
Screen pine no quotes, no second line, not Pine

C# here is not ASP.NET

ASP.NET builds web apps. Unity builds games. This tutorial teaches small console programs: a class, Main, types, decisions, loops, methods, objects, lists, files, and a caught error on the core path. Keep those other products off this introduction. If a leftover home card still talks about a full .NET ecosystem pitch, the teaching job today is still one screen word from Pine.cs.
Without Console.WriteLine, this teaching shape has no screen line. Without the quotes around pine, the writing line is no longer that text literal. Without Main, the runtime has no entry in this shape. Keep the writing line, the quotes, and Main together when you practice reading the file.

Reading before installing

You are reading the file on this page. You are not installing the SDK yet. You are not typing dotnet run yet. The next page installs C# / .NET on the computer and runs a first file. After that run, the screen you care about is still a short word like pine when you keep this writing shape. Today, predict the screen from the quotes. Tomorrow, install and run.
If the file still says Console.WriteLine("Pine"); with a capital P inside the quotes, the screen would show Pine, not pine. Restore the teaching literal pine for this page so class name and screen word stay easy to contrast. If you pasted a Java System.out.println("mint") line into a .cs file, switch back to Console.WriteLine("pine"); — that is the C# writing call on this course.

Before Install C

You can keep public class Pine, keep Main, import System, call Console.WriteLine("pine");, and say the screen will show pine with no quotes and no second line. The table separates file, class, entry, writing line, and screen. The next page is Install C#.
Keep the Pine demo for a clear first screen word. Keep ASP.NET folders off this page when you practice the introduction. Keep inventing long multi-print demos off this page. Those habits are the checkpoint before install. When you can point at Console.WriteLine("pine"); and name the screen pine, the introduction did its job and you are ready for Install C# if you continue.
One last pass through the file: using System; present, public class Pine, Main present, writing line with "pine", no Scanner story from other languages, no web route required. Read the writing line once more. If the word between the quotes is still pine, the first C# shape is solid and the course can move to install on the next page. Prefer one clear screen word per read so each pass teaches the same map.
Read the braces once as grouping marks, not as screen text. Read the semicolon at the end of Console.WriteLine("pine"); as the end of that statement, not as a character the screen prints. Keep the teaching file short enough that one writing line stays easy to find. When those habits hold, you can open Install C# without carrying a wrong screen guess from this page.

🧠 Test Your Knowledge

Ready to Start

Test Your Knowledge

Challenge yourself with this interactive quiz and see how well you understand the topic

❓
5
Questions
🎯
70%
To Pass
♾️
∞
Time
🔄
∞
Attempts

📝 Instructions

  • Read each question carefully
  • Select the best answer for each question
  • You can retake the quiz as many times as you want
  • Your progress will be shown at the top