Common Type System - Type Categories

Type Categories

The common type system supports two general categories of types:

Value types
Value types directly contain their data, and instances of value types are either allocated on the stack or allocated inline in a structure. Value types can be built-in (implemented by the runtime), user-defined, or enumerations.
Reference types
Reference types store a reference to the value's memory address, and are allocated on the heap. Reference types can be self-describing types, pointer types, or interface types. The type of a reference type can be determined from values of self-describing types. Self-describing types are further split into arrays and class types. The class types are user-defined classes, boxed value types, and delegates.

The following example written in Visual Basic .NET shows the difference between reference types and value types:

Imports System Class Class1 Public Value As Integer = 0 End Class 'Class1 Class Test Shared Sub Main Dim val1 As Integer = 0 Dim val2 As Integer = val1 val2 = 123 Dim ref1 As New Class1 Dim ref2 As Class1 = ref1 ref2.Value = 123 Console.WriteLine("Values: {0}, {1}", val1, val2) Console.WriteLine("Refs: {0}, {1}", ref1.Value, ref2.Value) End Sub 'Main End Class 'Test

The output of the above example

Values: 0, 123 Refs: 123, 123

Read more about this topic:  Common Type System

Famous quotes containing the words type and/or categories:

    “... In truth I find it ridiculous that a man of his intelligence suffer over this type of person, who is not even interesting, for she is said to be foolish”, she added with all the wisdom of people who are not in love, who find that a sensible man should only be unhappy over a person who is worthwhile; it is almost tantamount to being surprised that anyone deign having cholera for having been infected with a creature as small as the vibrio bacilla.
    Marcel Proust (1871–1922)

    All cultural change reduces itself to a difference of categories. All revolutions, whether in the sciences or world history, occur merely because spirit has changed its categories in order to understand and examine what belongs to it, in order to possess and grasp itself in a truer, deeper, more intimate and unified manner.
    Georg Wilhelm Friedrich Hegel (1770–1831)