Learn to Code via Tutorials on Repl.it!

← Back to all posts
C# FULL Beginners Crash Course

C# Full Beginners Crash Course

Hello fellow replitors.

This course is dedicated to me.


Let's get started.

Table of contents

  • Introduction
  • Setup
  • Overview of a basic C# file
  • Hello, World!
  • Variables
  • Basic OOP Overview
  • Input
  • Functions
  • IF Statement
  • WHILE Loop
  • FOR Loop
  • Interesting Features
  • In-Depth OOP
  • Where to go from here
  • Conclusion
  • Bibliography


C# is an Object-Oriented, strongly typed, and overall great language developed by Microsoft in 2000.

It is kind of a Java-Wannabe.

In terms of this it wants to be cross-platform but barely.

It works great on windows but not so well on other platforms.

Today we will be focusing on the cross-platform side of C#

It is still a great language though.


This course is accelerated so I will not be going in depth in many topics, for instance what an array is. Mainly this tutorial will be HOWs and all WHYs will mainly be about best practices and not metaphors.

This course is aimed at people with a Python, Java, C, or C++ background.

If you know HTML, CSS, JS, TS, Ruby, or anything else you can still learn but it may be slightly harder.

The course will NOT teach you an IDE you can use repl.it or learn an IDE but I am not here to teach you an IDE.

But without further ado let's get a move on.


For NOW use repl.it but later I'd recommend using a real IDE and or compiler.

Overview of a basic C# file.

Let's break down the file.

using System;? Well that is kind of like a #include or import statement. It's how we include new commands in our program.

The MainClass class is well, a class.

If you have no idea what a class is here is a basic overview.

Think about you driving a car the car has attributes, speed, brand, model, ect.

This car also has methods like starting it up, moving it, ect.

So, this is kind of like a class.

The class has methods and attributes,

Kind of like a data type.

The data type int might have a method called makeNegative() and an attribute called value.

Does that make sense?

Anyway public static void Main (string[] args) wow that is a mouthfull.

This is an example of a method!

The public is an identifier saying who can access this variable. See private.

The static means that the value of this method can never change.

The void means that this method returns nothing.

Main is the name. You must have a main class in your program for it to run and compile.

The (string[] args) is hard to explain if you don't come from a Java background.

When the user runs the program, they can specify args: myprogram.exe arg1 arg2.

And it turns them into a string array.

So you can reference them in your function!

Make sense?

Hello, World!

Okay finally, results!

So printing to the console is as easy as this:

Notice that most lines in C# end with a semicolon or a bracket.

Also C# is cAsE seNsiTivE so remember that.

The Console is a class in the System library that we imported using using System;.

And WriteLine is a method of Console.

This method takes a string type as an argument. We will go in depth on data types in the next section.


In this section we will discuss Variables and Data Types in C#

Data Types

  • int , a 32-bit signed integer
  • float , a 32-bit signed floating point value.
  • long , a 64-bit signed integer
  • double , a 64-bit signed number (decimal or not)
  • byte , a 8-bit signed integer
  • bool , a True, False value (1 byte)
  • char , a single unicode character a, b, c, ect. Surrounded by 's
  • string , multiple char types abc, def, ghi, ect. Surrounded by "s

Declaring Variables without giving them an immidiate value.

Consider the code below

The syntax is <type> <name>;.

Declaring & Assigning a variable.

The syntax is <type> <name> = <value>;.

Examples of various variable assignments

Some types in C# have special ways to assign them.

Lets review these.


We put an f at the end because the value defaults to a double type.



We put 's around the value to indicate that we are using a char type.


We put "s around the value to indicate that we are using a string type.

That's about it for basic variables.

Basic OOP Overview.

OOP or Object Oriented Programming is the fork of programming revolving around classes and such.

If you do Java or C++ this is probably engraved into your mind anyway.

We discussed Classes a bit in the section Hello, World!.

They have methods and attributes.


  • Member - (Methods & Attributes)
  • Instance - A object using that class
  • Method - a function in that class
  • Attribute - a sort of identifier but not really.

We will review how to make classes, methods, ect. in the section In-Depth OOP.


Short section but still important.

So to read a line we can do.

And this will return a value of type string that is the input.

So we can do.

To read a single key without the user having to press enter afterword we can do:

And it returns a char.


Okay, functions or methods are really easy.


Identifiers are things that can tell the compiler who can access this class/method, if it can ever change, ect.

Let's go over a few.

Access Modifiers

  • public - everyone can access this.
  • private - can only be accessed in the class itself
  • internal - can only be accessed in the current project assembly.
  • protected - can only be accessed within the class or any classes that inherit from the class

Other Modifiers

  • static - only instanciated once and never reinstated.
  • abstract - tells the compiler that the object being changed has a missing or incomplete implementation.
  • virtual - used to change a method, property, indexer, or event declaration and allow for it to be overridden in a derived class.
  • const - used with variables to declare that its value can never change


Consider the example below:

The syntax is <modifiers> <return_type> <name> (<args>)

Darn that is a headache, let's break this down.

The modifiers are things like protected or abstract.

The return type is what the function returns (data type).

The return type in the example above is void that means that the function returns nothing.

The name is a way to reference the function.

The args have their own syntax:

<type> <name>

They are function-scope variables.

The code in the function must be in brackets.

IF statement.

Logic, finally.

Okay so if you are not familiar with an if statement, then learn more of your best language then come back here.

But we can show you syntax here:


  • != - Does not equal
  • == - equals
  • >= or => - greater than or equal to
  • <= or =< - less than or equal to.
  • > - greater than
  • < - less than
  • && - and
  • || - or

Else if and Else

Else if has the same syntax as if, it executes if the prior if and or else if statements weren't executed but this condition is true.

Else statements executes if the prior if and else if statements werent true:



As much as I despise the WHILE Loop and encourage the FOR Loop most people love the WHILE Loop.

So I need to cover it.

The syntax is:

And the same operators can be used in the WHILE Loop as well as in the IF statement.

That is pretty much it, haha.

FOR Loop

Statement 1 runs one time before the execution of the code.

Statement 2 defines the condition for executing the code.

Statement 3 runs every time after the code is executed.

Interesting Features

C# .NET comes with many different features.

Let's Look at a few.


It makes a beeping sound. Doesn't work on repl.it.




It increments the value by 1.

In-Depth OOP

Okay this section is going to be really big. Just kiding I'm going to make it as quick and simple as possible


I hope at this point you understand what a class is.


The modifiers are the same as in functions section.




As defined in Basic OOP Overview. these are kind of like indentifiers except not.

They are a whole other fork and I won't really show you how to make them but I want you to know what they are.

But I'll show you an example from the Microsoft Documentation:

A method with the attribute DllImportAttribute is declared.

Okay so yeah they are kinda difficult.


Take this example from the Microsoft Documentation:

Inheritance is the act of one class inheriting from another.

Again a very in-depth field.

Where to go from here.

I'd suggest making a few programs and checking out the Microsoft Documentation.

C# is a very expansive language. And there is so much you can do with it.

There are so many jobs in C#

But if you wanted to learn more from me comment down below that you want to see an Intermediate Course.


Well. Upvote, feedback.


Works Cited

BillWagner. “C# Docs - Get Started, Tutorials, Reference.” Microsoft.Com, 2019, docs.microsoft.com/en-us/dotnet/csharp/.

“C# Tutorial - Tutorialspoint.” Www.Tutorialspoint.Com, www.tutorialspoint.com/csharp/index.htm.

“C# Tutorial (C Sharp).” W3schools.Com, 2019, www.w3schools.com/cs/.


Now this is the GOOD SH— stuff. The good stuff.


LOL! Yeah, I've dropped Assembly and moved on to C#. Might do Swift or F# after this dies down. @Highwayman


@Wuru You evil spammer. One thing you forgot: https://repl.it/talk/learn/n-and-n/43252


okay boomer @johnstev111


@Wuru Add the fact that they return values, or dfkjghasghkljshfgkjadhfgkjdhskljdsfghldkjsghkljdfhgldjshgldkjs.


Oo Swift! I’ve been looking at it, and it’s a very interesting language idea at least... @Wuru


Ya know I have an interesting little right up on n++ vs ++n in my repls somewhere.... @johnstev111


@Highwayman don't you mean write-up?


Ye write-up lol sry bout that typo XD @johnstev111


@Highwayman sorry about being pedantic, i sometimes am


It’s perfectly fine, I am in fact seriously thankful for the catch, thank you. Lol. @johnstev111


did you just go from hello world to OOP in one tutorial?
i'm not interested in C# right now but this tutorial will help!
great work!


thank you! @potatojs


Not really in depth. you just wrote n++ ++n you didn't even talk about incrementing after or before.


For those who don't know what's the diffrence.
If ++ is before the variable it means it will add before using the new value.
if ++ is used after the variable it will use the current value befor increasing it.


Hey nice! I guess this is pretty gud


this is cool.

i want an intermediate course.


okay. @nk1rwc


@Wuru i also want an f# tutorial


Nicely written. Now that C# has some attention, maybe Repl.it will finally add .NET soon...


I’ve never really understood what .NET is... care to explain? @SixBeeps


@Highwayman .NET has a bunch of built-in functions and stuff that speeds up the development process by a grand magnitude. The problem is, some functionality that other languages would call essential is locked in .NET, such as JSON, modern web requests, and GUI (although I doubt Repl.it would implement WPF because of a lower demand). Sure, you could code that all by hand, and sure there are older libraries for some of those things, but either way there's still a lot of functionality we're missing without the .NET core.


So, .NET is like stdlib for c++...??? I think I’m still confused. :/ @SixBeeps


@Highwayman Not quite. We have a stdlib, but barely anything else.


Oh. Ok so then is it like an environment or something? Like you say it adds extensions, so is it like it makes it possible to use certain aspects of the Lang bc... agh. @SixBeeps


@Highwayman If you understand what a DLL does, basically it's just a collection of a bunch of them that do a variety of tasks,


Ahhh ok I see now thank you :) @SixBeeps


Hrmmm time for me to spend 2 hours on that only for it to fail
Eh I'll try anyways @SixBeeps


I demand a CSGO hacking course with VMWARE and C#


@Jakman, Why do you want to hack CounterStrikeGlobalOffensive


@AbhayBhat I have before. He seems to be knowledgeable about C# so game hacking won't be that hard for him.


@Jakman, REALLY, COOL. My friend is like really good at CSGO. I wonder if he ever hacked


Been doing C# for 4 years now. F# is better though. And yes, I can hack CSGO with ease. @Jakman


Good. as a note that you could add to the tutorial. C# exists because Java could be used on any OS which Microsoft did not like. So they made C# os dependent on what Windows ran on for the most part. And it just so happened that they had the same syntax and semantic styling.


@Jakman, Lol Yeah.


lol you inspired me to finnally post my tutorial on basic cyber safety


Cool! Now I know how C#'s syntax works. now I can do Unity Better! Thanks a lot!


No problem :) @AbhayBhat


Awesome!! Beste tutorial ever!! Waw