Learn to Code via Tutorials on Repl.it!

← Back to all posts
C# - the basics! (part one)
firefish (1004)

Wheelcome to my tutorial on C#! Today we'll be covering the basics of C#!


You declare variables like this:
DataType varname;
You declare variables and assign like this:
DataType varname = value;
You assign variables like this:
varname = value;


Imports a namespace. Every program must start with using System; or you will create messy code.

namespaces and classes

C# is object oriented, so you can't store methods outside of classes. And you can optionally put classes in a namespace (to group them)!


The entry point is public void Main(), similar to int main() in C++.

Data type number 1: int a.k.a. System.Int32

The signed 32-bit integer.
e.g. int countq = 1;

Data type number 2: string a.k.a. System.String

A string.
e.g. string textext = "lol";

That's the basics FOR NOW. Let's look at methods!


This method is like print() in python, or std::cout << yourstring in C++.
e.g. Console.WriteLine("Er... Hi?");


Reads input. Like input() in python or std::cin >> somevariable in C++.
e.g. string usrInput = Console.ReadLine();

More coming soon!