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


Please Help Members By Posting Answers For Below Questions

Explain about appdomains?

597


Explain the use of virtual, sealed, override, and abstract.

558


how to add list of items in a web application and win application?

1593


Explain what does the term "green architecture" mean? : .NET Architecture

515


can u give me real example of how web.config overrides the machine.config file?

1280






What is IL code, CLR, CTS, GAC & GC?

587


What is .net mobile images control. : Microsoft dot net mobile

488


What is .net mobile input validation. : Microsoft dot net mobile

518


What is different about namespace declaration when comparing that to package declaration in java?

551


Explain about httpruntime.cach.get(); method?

565


Explain dma? : .NET Architecture

532


Explain some of the disadvantages due to microsoft.net?

533


Does application frame need host?

486


Can you explain atlasuiglitz library?

517


Explain how cache is used? : Dot net architecture

579