Skip to main content

Introduction to C# in Unity3D #5: Variables 📦

By February 3, 2021February 11th, 2021No Comments
C# Data types
📦 A variable is a reference to some value in memory (either stack or heap)
📦Think of it as a container for holding a value.
📦C# is a strongly typed language. In C# when you declare and initialize a variable you must specify the data type of the value that the variable will hold/reference, followed by the variable name and then assign it a value:


[Data Type] [Variable Name] = [Value];

For example:

int num = 75;

Out here int is a data type, num is the variable name (also known as an identifier). The = operator assigns a value to a variable. The right side of the = operator is a value that will be assigned to the variable. in this case it is the integer 75. The variable name and the data type that the variable references is on the left side of the = operator.


int num_1 = 10;
float rate = 10.2F;
char code = 'A';
bool isTrue = true;
string my_name = "Kauress";

Leave a Reply