Data types specify the size and type of values that can be stored.C# is a language rich in data types.
The types in C# are primarily divided into categories:
* Value type
* Reference types
But how these two types are differ with each other.Let us see
* Where they are stored in the memory
* How they behave in the context of assignment statements
Value types which is fixed in size(fixed length) are store on the stack.When a value of a variable is assigned to another variable,the value is actually copied.These means that two identical copies of the value are available in memory.
Reference types which are of variable length are stored on the heap, and when an assignment between two reference variables occurs, only the reference is copied; the actual value remains in the same memory location.This means that there are two references to a single value.
A third categories of types called pointers is available for use only in unsafe code.
The types in C# are primarily divided into categories:
* Value type
* Reference types
But how these two types are differ with each other.Let us see
* Where they are stored in the memory
* How they behave in the context of assignment statements
Value types which is fixed in size(fixed length) are store on the stack.When a value of a variable is assigned to another variable,the value is actually copied.These means that two identical copies of the value are available in memory.
Reference types which are of variable length are stored on the heap, and when an assignment between two reference variables occurs, only the reference is copied; the actual value remains in the same memory location.This means that there are two references to a single value.
A third categories of types called pointers is available for use only in unsafe code.
No comments:
Post a Comment