DEV Community

staticalliam7
staticalliam7

Posted on

C#: the basics

Hello Guys!

Ok, so today I'm going to introduce the theoretical stuff of C# (btw this Will be useful later).

Variables

What is a variable anyway?

Well, a variable is a reserved place in your computer's RAM (Ramdom Access Memory), that can be edited. (note that in some languages, like Rust, variables are constants by default)

Types of Variables.

  • bool This can only hold 2 values, true or false
  • string This can hold multiple alphanumeric and special characters, such as "hello world"
  • char This can only hold a single alphanumeric (or special) character
  • Integer This can hold a single numeric value
  • double This can hold a single decimal value > Notice! > There are TONS more types then this but for the sake of space (and me being lazy lol), I'm not going to list them all.

Constants

These are basically just normal variables but they cannot be edited

Notice!
These are NOT declared normally
Example:

const string = "hello";

ERRORS

SYNTAX ERRORS

A syntax error is a:

  • spelling error
  • missing character

Screenshot 2020-03-01 at 19.04.40

LOGIC ERRORS

These are basically mathematical errors or misspelling of variables
Example:

Screenshot 2020-03-01 at 19.38.05

You may be wondering: Why? it looks fine

Well, it's not. If you look closer it's simple. You just made a capitalization error

RUNTIME ERRORS

These are nearly undetectable
some signs are:

  • low memory
  • division by zero

Good Programming Practices

- Indentation

- Commenting

Example:
//this is a comment

Hope this helped, i will be releasing another part in like a week or something idk

Top comments (0)