ECMA-334: 11.1 Value types

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
C# Language Specification
© 2006 ECMA International

11.1 Value types

A value type is either a struct type or an enumeration type. C# provides a set of predefined struct types called the simple types. The simple types are identified through reserved words.

value-type:
struct-type
enum-type
struct-type:
type-name
simple-type
nullable-type
simple-type:
numeric-type
bool
numeric-type:
integral-type
floating-point-type
decimal
integral-type:
sbyte
byte
short
ushort
int
uint
long
ulong
char
floating-point-type:
float
double
enum-type:
type-name
nullable-type:
non-nullable-value-type ?
non-nullable-value-type:
enum-type
type-name
simple-type

All value types implicitly inherit from class object. It is not possible for any type to derive from a value type, and value types are thus implicitly sealed (§17.1.1.2).

A variable of a value type always contains a value of that type. Unlike reference types, it is not possible for a value of a value type to be null, or to reference an object of a more derived type.

Assignment to a variable of a value type creates a copy of the value being assigned. This differs from assignment to a variable of a reference type, which copies the reference but not the object identified by the reference.


Today's Deals: Electronics

Personal tools