what is the difference between value types and reference
types?
Answer Posted / susant
Value type - bool, byte, decimal, double, enum , float,
int, long, short, strut, uint, ulong,
Value types are stored in the Stack
Reference type - class, delegate, interface, object, string
Reference types are stored in the Heap
Value types : Value types directly contain their data, and
instances of value types are either allocated on the stack
or allocated inline in a structure. Value types can be
built-in (implemented by the runtime), user-defined, or
enumerations.
Reference types : Reference types store a reference to the
value's memory address, and are allocated on the heap.
Reference types can be self-describing types, pointer
types, or interface types. The type of a reference type can
be determined from values of self-describing types. Self-
describing types are further split into arrays and class
types. The class types are user-defined classes, boxed
value types, and delegates.
Variables that are value types each have their own copy of
the data, and therefore operations on one variable do not
affect other variables. Variables that are reference types
can refer to the same object; therefore, operations on one
variable can affect the same object referred to by another
variable. All types derive from the System.Object base type.
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
Name some changes done since version 3.0?
What is different about namespace declaration when comparing that to package declaration in java?
How cache coherency is eliminated? : Dot net architecture
Explain difference between machine config vs. Web config? : .NET Architecture
Is dim fs as filestreamobject is a managed code? : Dot net architecture
how to delete the record using data reader
Difference between throw exception and rethrowing ?
What is the difference between an application and a program?
Define a virtual memory? : Dot net architecture
Explain .net mobile automatic paging? : Microsoft dot net mobile
Define cache coherency? : Dot net architecture
Explain dma? : .NET Architecture
Differnce between managed code and unmanaged code ?
how to use custom field validation
What is the cli? Is it the same as the clr?