Data Structures and Algorithms with Object-Oriented Design Patterns in C#
next up previous contents index

Value Types

The C# value types are the simple types, the enumerated types, and structs. The simple types   are bool, char, byte, sbyte, short, ushort, int, uint, long, ulong, float, double, and decimal. The C# language specification[22] defines the range of values for each simple type and the set of operations supported by each type. The enumerated types   are declared using the C# enum construct. C# structs   are declared using the struct construct.

Every variable of a value type is a distinct instance of that type. Thus, an assignment statement such as

y = x;
takes the value of the variable x and copies that value into the variable y. After the assignment, x and y remain distinct instances that happen to have equal values.

A comparison of the the form

if (x == y)
    { /* ... */ }
tests whether the values contained in the variables x and y are equal.


next up previous contents index

Bruno Copyright © 2001 by Bruno R. Preiss, P.Eng. All rights reserved.