This Week’s Programming Lesson: C# Lesson 2
Read this in plain English: “Read the user’s input, turn it into a whole number, and store it in a variable called score.”
Tech / Development / Sep 21, 2026 / Roguegoose1
This Week’s Programming Lesson: C# Lesson 2
Learning to Read and Store Simple Information
Last week we kept things extremely simple.
We wrote Hello, World! again and again until
typing C# started to feel a little less strange.
This week we are going to build on that. Not by building a
full application nor by doing anything complicated. We are just going to let
the computer ask for information, store it, and print it back out.
That means we are going to work with a few basic C# types:
- string
- int
- float
- bool
And we are going to use Console.ReadLine() so the
program can read what the user types.
Start with a Question
Let’s begin with something very simple:
If you run that, the computer will ask for your name.
You type it in, press Enter, and then the program says hello
back to you.
That is already a lot more interesting than Hello,
World!, but it is still very simple.
What is Happening Here?
Let’s read this like English.
Console.Write("What is your name? ");
We can read that in English as:
“Print What is your name? to the console.”
We use Write instead
of WriteLine because we want the cursor to stay on the same line.
That way the user can type their answer right after the
question.
string playerName = Console.ReadLine();
Which, in English, is:
“Make a variable called playerName to store text in, then wait for
the user to type something and press Enter.”
A string is for text.
Console.ReadLine() reads whatever the user typed.
Console.WriteLine("Hello, " + playerName);
Which is:
“Print Hello, and whatever input the user gave us.”
So if the user typed Steve, the console will print:
Hello, Steve
It takes the word "Hello, " and adds the
value stored in playerName.
Add a Whole Number
Now let’s add another piece of information.
Now the program asks for a name and a score.
The name is stored in a string.
The score is stored in an int.
An int is a whole number, such as, 1, 2, 4, 10,
38000. Not decimals.
And hy do we use int.Parse?
Well, Console.ReadLine() always gives us text.
Even if the user types a number, the computer reads it as
text first.
So, if we want a number, we have to convert that text into a
number.
That is what int.Parse() does.
int score = int.Parse(Console.ReadLine());
Read this in plain English:
“Read the user’s input, turn it into a whole number, and
store it in a variable called score.”
Add a Second Number
Now let’s make the example feel a little more like something
we might build later.
Now we are storing more than one number.
That is important because real programs usually do not just
keep one piece of information.
Now, a float. A float is a number that can include
decimals.
Again, Console.ReadLine() gives us text first, so
we use float.Parse() to turn that text into a number with decimals.
This is useful for values that are not always whole numbers.
Add a True or False Value, Known as a Bool
A bool is short for Boolean and is a true or false
value.
So, if the program asks whether the game is over, you can
type true or false.
That is enough for now.
We do not need to make it more complicated than that.
Our Exercise for the Week
For the next week, and 10 times per day minimum, I want you type
out the entire program. As you do, read it as in English. Do it aloud if you
can.
And repeat.
That is how the shapes of C# start becoming familiar.
Try This Version First
That’s It for This Week
Write it, read it, ten times per day.
That may sound like a lot, but I you take it one step at a
time, read it aloud as you go, you will understand it in no time.
And that is where programming starts to get useful.