Explain the Difference between value and reference type.
Answer Posted / suhasini suresh
Reference types are stored on the run-time heap; they may
only be accessed through a reference to that storage. This
allows the garbage collector to track outstanding
references to a particular instance and free the instance
when no references remain. A variable of reference type
always contains a reference to a value of that type or a
null reference. A null reference refers to nothing; it is
invalid to do anything with a null reference except assign
it. Assignment to a variable of a reference type creates a
copy of the reference, not a copy of the value being
referenced.
Value types are stored directly on the stack, either within
an array or within another type. When the location
containing a value type instance is destroyed, the value
type instance is also destroyed. Value types are always
accessed directly; it is not possible to create a reference
to a value type. Prohibiting such a reference makes it
impossible to refer to a value class instance that has been
destroyed. A variable of a value type always contains a
value of that type. Unlike reference types, the value of a
value type cannot be a null reference, nor can it reference
an object of a more derived type. Assignment to a variable
of a value type creates a copy of the value being assigned.
| Is This Answer Correct ? | 10 Yes | 3 No |
Post New Answer View All Answers
Explain the different parts of an assembly?
Explain re-clarification of object based in .net?
Which namespace is used to support multithearding in .NET?
How will you do redo and undo in textbox control?
How viewstate is being formed and how it is stored on client in .net?
Explain the differences between server-side code and client-side code.
What does msil do?
What is a variable of implicit type and what is its scope?
Tell us the difference between the while and for loop. Provide a .net syntax for both loops?
Name the classes that are introduced in the system.numerics namespace.
What are the different.net tools which you used in projects?
What is the use of UML in .Net
Is .net core managed code?
What is data type and how many types of data types are in .NET ?
A developer company sends dlls to the client. Some client is not happy current functionality, so request some modification. Developer made some changes and send new dll to all clients. Some client is happy with old version, tell me minimal change to so that neither clients get affected?