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
How to implement datagrid in.net? How would you make a combo-box appear in one column of a datagrid? What are the ways to show data grid inside a data grid for a master details type of tables? If we write any code for datagrid methods. What is the access specifier used for that methods in the code behind file and why?
Explain me what is encapsulation?
Explain about .Net products?
Explain what is a delegate?
Write a program to create a user control with name and surname as data members and login as method and also the code to call it.
What are the purposes of using .net?
Explain the different parts of an assembly?
Can you write a class without specifying namespace?
Can you edit data in repeater control? How?
What are an object and a class?
What is the difference between asp.net & vb.net and explain architecture?
Define code access security (cas)?
Name the classes that are introduced in the system.numerics namespace.
Explain me what is .net web service?
Explain what inheritance is, and why it's important?