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

Leave a Reply

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