Five Different Variables in C#
In coding there are five different variable data types, and its very important to understand how they work.
Variables have two different privacy options. The first is public, which allows every script to access that variable.
If I were to try and access the variable from a different script, it would be used. However, the private option only allows the script that its in to access it, meaning no other script can use it.
Now it is time to go over the five different data types of variables at your disposal.
The first variable is int. These types of variables contain integer values. Int variables are often used for storing data that need to be displayed as whole numbers. Such as the amount of hit points, how much durability is left on a weapon, etc.
The second variable is float. Unlike int, float can hold decimal values. These can be used for more precise borders, movement, and more! Just remember to add an “f” after typing in the number of your choice. You will get a running error if you don’t.
The third variable is string. Unlike float and int, string can hold words and sentences. These can be used for messages.
The fourth variable is called char. Char is structured like string, but it can only hold a single letter or number
Finally, the last variable are bool. Simply put, bool or booleans is just a true or false statement. These can be used for if loops.
That wraps up this guide for different types of variables. If you like my guides, check out other guides I write about Unity and C#!