There are three kinds of types in C#.
- Value types
- Reference types
- Pointer types
Value Types
Value types directly contain their data. Each variable of a value type has its own copy of the data. Value types are typically allocated on the stack plus are automatically destroyed when the variable goes out of scope. Value types include the elementary types discussed in Chapter 4, structures, plus enumeration types.
Reference Types
Reference types do not contain data directly but only refer to data. Variables of reference types store references to data, called objects. Six different variables can reference the same object. Reference types are allocated on the managed heap & finally get destroyed through a scheme known as garbage collection.
Reference types include string, object, class types, array types, interfaces, and delegates.
Pointer Types
In a context of insecurity, a type can be a pointer type and a value type or a reference type. A pointer type declaration takes one of the following ways:
type* identifier;
void* identifier; //allowed but not recommended
0 comments:
Post a Comment