Data types , Variables and Constant in C# Unity3D
Data : Raw facts and rough figures are called Data
Information : The processed data is called information.
In developing a game we need various type of data. These data are stored in different ways and they will be reused or modified.
To handle the data we have different medium to store it. Data is categorized as either Variables or constant.
Variable :Variable is an identifier which are used to store values and it can change during execution.
eg: Score in the game
Constant :Constant can never change during program execution
eg: Gravitational force , value of pi…
Steps for creating variables
- Create a Variable with some meaningful name — declaration statement
type variableName;
2.Store values in that variable — assignment statement
variableName=value;
3.Retrieve and access the stored value through the variable name.
Debug.Log(variableName);
Constant : Constant can be declared using const keyword with their datatype.
In C# data types can be classified mainly into two types Value and Reference type
Here I would like to say only about Simple Types .In C#, primitive data types are actually objects, It means when you write the following code, a variable rollNo is actually an Object.
int rollNo=8;
The most famous primitive data types are- int, object, short, char, float, double, char, bool. They are called primitive because they are the main built-in types, and could be used to build other data types . They stored actual data rather than referencing it.
when you create a variable from the primitive types, you are creating an instance from it’s structure.