GCSE Link: 2.02 (Data Types)

This definition is copied over from the page for GCSE:

The data type of a variable determines how its binary form in memory is interpreted.

The following table is similar to the one on the GCSE page.

Table 1 shows the seven main data types in C#.

Table 1

Name Description Example C# declaration
Integer A whole number. int minAge = 16;
Floating point (single precision) A number with a decimal part, stored using 32 bits. float height = 1.63f;
Floating point (double precision) A number with a decimal part, stored using 64 bits. double pi = 3.141592653589793;
Boolean Either "true" or "false". bool flag = false;
Character A single Unicode character. char currency = '£';
String A sequence of characters. String bestRevisionGuide = "CS.RN v2";
Date/Time A date and time. DateTime epoch = new DateTime(1970, 1, 1);

A pointer (or reference) stores the memory address of a variable.

They effectively "point to" where the data is being held, instead of storing it themselves.

Note: pointers don't exist in C# because they are deemed unsafe.

Because memory is assigned at runtime, the value of a pointer will always be different each time you run a program.



How do we convert between data types in pseudocode?

INT_TO_STRING(123)     "123"
STRING_TO_INT("123")   123
REAL_TO_STRING(1.23)   "1.23"
STRING_TO_REAL("1.23") 1.23