Data Type
Contents
Definition
A data type is an attribute of data that tells the compiler how the programmer intends on using the data. A data type limits the values that an expression might take.
Relevance
Explanation
Information falls under a different data type. Different data types are used for different intents: for math you may use integers, floats, doubles, etc. while for keeping a contact list, strings would be more appropriate. As mentioned before, data types limit which operations can be used on them. A string cannot be added to an integer because an integer can only be a whole number while a string can be a name, address, etc. However, an integer can be added to a string, this is known as Concatenation. It’s all about using the right data type for the right job.
Example
Here's an example of a few different types of variables being initialized:
string name = “John Doe”; |
int age = 20; |
bool isStudent= true; |
float payrate= 12.50f; |