Value Types
Value types are built-in data types that store values directly in their memory locations. Value types include:
Example:
int age = 30;
Example:
double pi = 3.14159;
Example:
char letter = 'A';
Example:
bool isStudent = true;
Reference Types
Reference types are built-in data types that store references to memory locations. Reference types include:
Example:
Person person = new Person();
Example:
string name = "John Doe";
Example:
int[] numbers = new int[5];
Nullable Types
Nullable types are value types that can also have a null value. Nullable types are represented using the ? suffix after the data type. For example, int? represents a nullable integer, and bool? represents a nullable boolean.
Example:
int? age = null;
User-Defined Types
User-defined types are types that are defined by the programmer. These include:
Example:
struct Point
{
public int x;
public int y;
}
Example:
enum DayOfWeek
{
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday
}
Please support us by disabling your ad blocker for this website.
We rely on advertising revenue to keep the lights on and content free.
Thank you for understanding ❤️