Press "Enter" to skip to content

Lesson 00.2 – General information about programming in C#

Before you write your first program in C#, you need to know a few general things about programming.

 

C# is case-sensitive

When you name anything in C# (class, variable, function, etc.), the casing you use is important. “Player” is different from “player” and “PLAYER”.

It usually doesn’t matter what you use, as long as you are consistent.

However, there are some standards that many C# programmers use. If you get used to them now, that will make it easier for you to read other programs, or have other programmers read your programs.

The standards I’ll use while building this game are fairly common.

 

Visual Studio is the “editor” we will use

An editor is basically a word processor for your program.

With a word processor, you can type a document, makes changes to it, and have it check if the spelling and grammar is correct.

An editor lets you do similar things with your programs.

 

C# is a “high-level” language

This means is that C# looks similar to natural English – well, at a certain level.

Computers really only understand machine language, a very low-level language, which doesn’t look anything like English. So it’s much easier to program in a high-level language, and letting the computer compile that into a low-level language.

 

What are functions, procedures, and methods?

These are all names we use to describe a small piece of a program that does a specific thing.

For example, in this game we’re going to fight monsters. When the player clicks on the “Attack” button, we need to determine a random amount of damage to apply to the monster. So, we’ll create a function to determine this random number.

By having this piece of the program in a function, we can use it in several different places in the program. Once the player defeats a monster, we want to randomly determine what “loot” the player gets from the monster. So, we can use this same random number function for that.

 

What is compiling/building?

Before a computer can run a C# program, the program needs to be converted into something a computer can read. This is called compiling.

In Visual Studio, you compile your program by either selecting the “Build” menu option or the “Start” menu option (which compiles the program and then runs it).

 

Next Lesson: Lesson 00.3 – The parts of Visual Studio

Previous lesson: Lesson 00.1 – What is in these lessons?

All lessons: Learn C# by Building a Simple RPG Index

4 Comments

  1. J.
    J. May 20, 2021

    I cant access any lessons past 3.1, because my page is stuck loading, and it never loads all the way. Is there a way I can fix this?

    • Scott Lilly
      Scott Lilly May 20, 2021

      Hi J.,

      It looks like there was a problem on the web server. Can you try again and let me know if the problem still happens?

      • J.
        J. May 20, 2021

        I had run a diagnostics test (about an hour ago) on the website, and it told me the CDN was the problem, so maybe that was the problem? Anyways, I just hopped on, and whatever you did fixed the problem, I can now access the lessons. Thank you for fixing it right away! Also thank you for these lessons, I’m sort of new to C# programming and I really appreciate these lessons!

        • Scott Lilly
          Scott Lilly May 20, 2021

          You’re welcome!

          It looks like it was either the Autoptimize or JetPack plugin for WordPress – or the combination of them working together. I don’t know the exact issue, because I just deactivated them to get the site working again. I’ll look into the problem more when I have some free time.

Leave a Reply to Scott Lilly Cancel reply

Your email address will not be published. Required fields are marked *