// Structures and enumerations extend System.ValueType.
public abstract class ValueType : object
{
public virtual bool Equals(object obj);
public virtual int GetHashCode();
public Type GetType();
public virtual string ToString();
}
Given the fact that value types are using value-based semantics, the lifetime of a structure
(which includes all numerical data types [int, float, etc.], as well as any enum or custom structure)
is very predictable. When a structure variable falls out of the defining scope, it is removed from
memory immediately:
// Local structures are popped off
// the stack when a method returns.
static void LocalValueTypes()
{
// Recall! "int" is really a System.Int32 structure.
int i = 0;
// Recall! Point is a structure type.
Point p = new Point();
}
Do'stlaringiz bilan baham: |