Explain the Difference between value and reference type.

Answers were Sorted based on User's Feedback



Explain the Difference between value and reference type...

Answer / 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

Explain the Difference between value and reference type...

Answer / kinjal

c# provides a set of datatypes. datatypes of c# contain two categories one is value type and another is reference type.

value type is a variable. datatype value store in variables while a variable of a reference type stores a reference to the data.

both value type and reference type have one common thing - both derived from system.object.

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More Dot Net General Interview Questions

How does the .NET framework work?

1 Answers  


Name the classes that are introduced in the system.numerics namespace.

0 Answers  


What is file extension of Webservices in .Net?

0 Answers   Arigo Infotech,


What are the contents of assembly?

4 Answers   ABC, Ksb,


Is there built-in support for logging?

0 Answers  






Is .net core free?

0 Answers  


What is the advantage of packaging over xcopy in .net?

0 Answers  


Name some of the languages .NET support?

3 Answers  


Is .NET a runtime service or a development platform?

2 Answers  


Different levels of priority provided by .net.

0 Answers  


you have a requirement from client, he has an XML file and you need to insert the data into 5-6 tables in database. explain me the procedure.

2 Answers   Deloitte,


Can you configure a .NET Remoting object via XML file?

1 Answers  


Categories