Syntax

Remarks

Introduction

Value types

Value types are the simpler of the two. Value types are often used to represent data itself. An integer, a Boolean or a point in 3D space are all examples of good value types.

Value types (structs) are declared by using the struct keyword. See the syntax section for an example of how to declare a new struct.

Generally speaking, We have 2 keywords that are used to declare value types:

Reference types

Reference types are slightly more complex. Reference types are traditional objects in the sense of Object Oriented Programming. So, they support inheritance (and the benefits there of) and also support finalizers.

In C# generally we have this reference types:

New reference types (classes) are declared using the class keyword. For an example, see the syntax section for how to declare a new reference type.

Major Differences

The major differences between reference types and value types can be seen below.

Value types exist on the stack, reference types exist on the heap