Getting Started with C# | C# Beginners (Part 1) | Table Flip Games

Getting Started with C# | C# Beginners (Part 1) | Table Flip Games


Hello and welcome to the C# Programming tutorial
series here on Table Flip Games. I’m Tommy
Thompson and this series will aim to guide
you through the fundamentals of how to get
started writing in the C# programming language.
This series is aimed very much at those who
have little to no experience at all in writing
in C#, or programming in general and is inspired
by classes I have taught in the early semesters
of undergraduate university courses on computer
science and games programming.
So first things first: welcome! In this series
I’m going to be focussing on programming from
the ground-up. Now if you’ve never written
programs before, you’re essentially writing
a series of instructions that can be executed
by a computer. Depending on what you want
to do and sometimes how you want to go about
it, you will use different programming languages
in order to pull that off.
This series is aimed at familiarising you
with the principles of the C# programming
language. A general purpose object Oriented
Programming: one of if not arguably the most
popular programming paradigm currently used
in the software industry. We opt to use C#
to build up your skill set in this area for
a number of reasons:
First-off: C# is the successor to a number
of programming languages that have adopted
object oriented principles such as C++ (used
in embedded systems and game engines such
as Unreal), Java (which is utilised in a large
amount of enterprise system development and
the Android operating system) and Objective-C
(which you use to write iPhone apps). C# is
very similar to many of these languages. Please
note I’m not saying one is better than the
other, but for a newcomer it’s pretty clean
to get to grips with: with many concepts found
in C++ and Java refined for ease-of-use in
C#.
What is important here is that we’re focussing
more on programming principles: as such, many
of the concepts we’re going to explore in
these videos are equally applicable in other
languages. You’ll just need to learn the syntax,
but we’re getting ahead of ourselves a little
here.
Secondly, C# is utilised in the Unity game
engine: a popular video game engine. As such,
if you don’t know the first thing about C#,
you can work through these videos before starting
to get to grips with my Unity tutorial series.
This series will look into a variety of topics
that you need to be able to know to work in
the language effectively. I’ve provided a
list of some of these topics below, but this
is far from exhaustive and aims to give you
a taste of what is to come.
This is of course not the full extent of what
C# can do as a language, but it’s enough to
help you begin to write your own small programs.
In addition, we will be taking the time to
look at some larger examples and break down
how to solve each of these problems as we
go.
Now before we can write any code, we need
to make sure you have everything you need
in order to write your C# code and manage
your projects. Now in this instance, I am
running this project on a PC running Windows
10 but you can still have a similar setup
using a Mac machine. There are two really
important components needed in order to get
started:
First up is visual studio: Microsoft’s integrated
development environment or IDE which is available
on both PC and Mac. This is where developers
write code, manage their source files, build
executables and run their software during
its development. It also contains all of the
back-end tools we need in order to build your
C# code into an actual program. So check the
link in the description to head to the Visual
Studio website. There are a number of paid-for
versions of Visual Studio, but we only require
the free version in order to get started.
The second item we need is a separate text
file editor, as I’m going to spend the first
couple of videos writing our code in Notepad++
and not in Visual Studio. Head over to the
link in the description or jump on Google
to download Notepad++. Now you might think
from looking at this, it looks quite similar
to Notepad or Wordpad on your PC already,
but it’s actually a lot more flexible and
versatile than that. As such, do go that extra
mile to install this piece of software too.
Now some of this, notably Visual Studio, is
going to take time to install and get running.
As such, we’re going to spend the rest of
this video discussing some basics of C# and
programming in general. So set off that Visual
Studio installer, then come back as I give
a brief overview on the basics of how programming
works.
–PROGRAMMING BASICS–
If you’re not familiar with how programming
works: the key thing to know is that computers
– by nature – are actually kinda stupid…
A computer will not perform an action unless
it is told to do so. As such, we can tell
the computer to execute specific operations
through instructions sent to the central processing
unit or CPU on board the machine. Now the
thing is, that was about the gist of things
well over 50 years ago, but not anymore.
Nowadays there are multiple layers between
the programmer and the CPU itself, which requires
operating systems to schedule multiple programs
their own time with the CPU every second.
Right now you’re watching this video either
on a computer via a web browser or on a phone
or tablet via a designated app. In each instance
the application is running on top of an operating
system which manages your device – itself
being comprised of lots of smaller programs
all needed to get things rolling. Now think
about all of the other programs you have running
on your device right now: that all adds up
and all of those programs get a tiny slice
of time every second to run a little bit of
their program to complete their specific task.
It’s why your computer sometimes slows down
if you do too many things at once – you’re
asking it to split up it’s time across more
and more programs all vying not just for CPU,
but the memory of the machine that is needed
to store information about the programs it
is running.
As I said earlier, your code will be telling
the CPU what particular instructions to do.
Thing is, the instructions your CPU can complete
are kinda basic and mostly revolve around
the completion of basic arithmetical operations
and storing information in registers (a holding
spot for data on the CPU). Now that doesn’t
really make for an easy and accommodating
method of getting started with programming.
Not to mention the fact that you achieve this
using what we call ‘machine code’: a set of
instructions that are encoded in lines of
binary digits (0’s and 1’s). Now just because
that’s how CPU’s operate, but it doesn’t mean
we still have to. Programming languages such
as C# are what we refer to as a high level
language: which enables us to write software
using terms and structure more similar to
human language. When we’re ready to run our
programs, we have to translate this high-level
language such as C# into machine code for
the computer to run it.
Now this gets us to one crucial element we
will be looking at in our opening videos:
the notion of using a compiler. A compiler
is a part of a set of programming language
tools that translates your C# program files
into machine language that will enable you
to run the program on the hardware. Right
now we’re only going to be writing in one
file, but after a few videos this will expand
into a projects with multiple files. The key
thing is, the compiler will gather all of
the files we’ve written, double check we’ve
written the program language statements correctly
and create the correspoding program executable
which can be ran on the computer. This is
a process known as compiling.
Now, there’s a pretty critical element of
what I just said here that I’m going to focus
on for the first few videos: compilers check
we’ve written program language statements
correctly: what that means is it checks what
we have written makes sense for that programming
language. If we have written anything that
is incorrect, the compiling process will fail
and the compiler will tell us what it found
wrong in the code. Think of it like a linguist
who is translating what you said, but needs
to be 100% sure of what you said before it
will make the full translated transcript.
We’ll be looking at how to cope with compiler
errors along the way and becoming more resilient
to dealing with them. You will create compiler
errors when writing your code and that’s ok,
it happens to all software developers – typically
on a daily basis, the only difference is that
developers such as myself a more comfortable
dealing with them. Well actually… there’s
usually a lot more cursing and swearing at
the computer but we’ll try and keep it out
of the videos.
As we will see throughout the series, some
of the biggest problems you might face are
when your program fails to compile, but you’re
not entirely sure why – given that the compiler
will complain when an error occurs, but it
can’t really tell you what exactly you did
wrong, but instead give a guess based upon
where it failed to translate your code. We’re
going to come back to talking about compiling
code and dealing with errors in upcoming videos.
So with that, I’ve covered my basic introduction
and covered a little bit of theory. So let’s
get to actually programming! In part 2 we’re
going to write what we call a ‘Hello World’
program. It’s the simplest program you can
write and will help us get to grips with writing
and compiling our code. Welcome aboard and
I look forward to seeing you in the next video!

2 thoughts on “Getting Started with C# | C# Beginners (Part 1) | Table Flip Games”

Leave a Reply

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