What is the Difference between value and reference type?

Answers were Sorted based on User's Feedback



What is the Difference between value and reference type?..

Answer / taranjeet

value type: when value is assigned to another
variable,values are copied.
refrence type: when assignment between two variable accures
only reference is copied value remain same

Is This Answer Correct ?    58 Yes 9 No

What is the Difference between value and reference type?..

Answer / ravi

1. value type contain variable and reference type are not
containing value directly in its memory.
2.memory is allocated in managed heapin reference type and
in value type memory allocated in stack.
3.reference type ex-class
value type-struct, enumeration

Is This Answer Correct ?    36 Yes 9 No

What is the Difference between value and reference type?..

Answer / saransony

C# provides a set of different data types. The data types
in C# are divided into two categories – Value Types and
Reference Types. Although there is a third data type –
pointers, Pointers can only be used in unsafe code.
A variable that is a value type, stores the data, while a
variable of a reference type stores a reference to the
data. Both Value Types and Reference Types have one
interesting thing in common – they both derive from System.
Object. This is interesting, because most other object-
oriented languages do not have this behavior.
Value Types
The value of value types is stored on the managed stack,
and can be used directly. This means that the value is
stored, and not a reference to the value. This also means
that each value type has its own copy of the data.
Reference Types on the other hand has a reference to the
data, and several variables can reference the same data.
Reference Types
In contrast to value types, the value of a reference types
is allocated on the heap. Another name for a reference
type, that you might be more familiar with, is an object.
Reference types stores the reference to the data, unlike
value types, that stores the value.
Links- http://www.programmersheaven.com/2/FAQ-CSHARP-
ValueRef-ValueType-Differences

http://msdn.microsoft.com/msdnmag/issues/1200/dotnet/
http://msdn2.microsoft.com/en-
us/library/2hf02550.aspx

http://dotnetsutra.blogspot.com/2007/10/difference-between-
value-type-and.html

Is This Answer Correct ?    22 Yes 7 No

What is the Difference between value and reference type?..

Answer / amit kumar

Value Type:
When you assign value to value type variable to
another variable then it's value only copy to another
variable. It allocates memory in stack. Here both variables
work independent.

Reference Type:
When you assign value to reference type variable to
another reference type variable then it's value doesn't
copy both variables are dependent to each other and if you
change one value it reflects in other one. It allocates
memory in the heap data structure.

Is This Answer Correct ?    25 Yes 12 No

What is the Difference between value and reference type?..

Answer / purish dwivedi

A variable that is a value type, stores the data, while a
variable of a reference type stores a reference to the data.
Value types are stored directly on the stack while Reference
types are stored on the run-time heap.

Is This Answer Correct ?    6 Yes 5 No

What is the Difference between value and reference type?..

Answer / rahul e. mankumare

Value Types:-
value types are struct type and enumeration.
value type have some types which are given below
1>numeric type
2>boolean tyoe
3>character type
value type contain some integral types means signed
integers and unsigned integer. floating-point,decimal types
are also comes under value type

Reference Types:-
it is user defined type. It contains classes,
interfaces, delegates, arrays also object and strings types.

Is This Answer Correct ?    5 Yes 4 No

What is the Difference between value and reference type?..

Answer / vishvam

What is the difference between value type and reference
type? Can a value type contain NULL values?

In simple words, all value based types are allocated on the
stack, while all reference based types are allocated on the
heap. What does this mean? A value type contains the actual
value. A reference type contains a reference to the value.
When a value type is assigned to another value type, it is
copied. When a reference type is assigned to another
reference type, a reference is assigned to the value.

By saying stack, we mean things are kept one on top of the
other. We keep track of each value at the top. By saying
heap, we mean things are kept in a mashed order. We keep
track of each value by its address, that is referenced by a
pointer to it.

All value types are implicitly derived from
System.ValueType. This class actually overrides the
implementation in System.Object, the base class for all
objects which is a reference type itself.

Data types like integers, floating point numbers, character
data, Boolean values, Enumerations and Structures are
examples of Value Types. Classes, Strings, Arrays are
examples of Reference Types.

A value type may not contain NULL values. Reference types
may contain NULL values.

It is not possible to derive new types from Value Types.
This is possible in Reference types. However, Value Types
like Structures can implement interfaces.

Is This Answer Correct ?    1 Yes 0 No

What is the Difference between value and reference type?..

Answer / ajay

whenever a datatype is defined based on a structure it is said to be value type datatype.
whenever a datatype is derived from class definition then it is said to be reference type datatype.

value type memory allocated in stack
reference type memory allocated in heap

Inheritance is not support by the Value type members
Inheritance is support by the Reference type members

Value type data type are byte,int,uint,float,Double,decimal,char and bool
Reference type data type are string,class,objects,Enwn,interface and delegates

Is This Answer Correct ?    6 Yes 6 No

What is the Difference between value and reference type?..

Answer / himani

In simple words, all value based types are allocated on the
stack, while all reference based types are allocated on the
heap. What does this mean? A value type contains the actual
value. A reference type contains a reference to the value.
When a value type is assigned to another value type, it is
copied. When a reference type is assigned to another
reference type, a reference is assigned to the value.

By saying stack, we mean things are kept one on top of the
other. We keep track of each value at the top. By saying
heap, we mean things are kept in a mashed order. We keep
track of each value by its address, that is referenced by a
pointer to it.

All value types are implicitly derived from
System.ValueType. This class actually overrides the
implementation in System.Object, the base class for all
objects which is a reference type itself.

Data types
like integers, floating point numbers, character data,
Boolean values
, Enumerations and Structures are examples of Value Types.
Classes, Strings, Arrays are examples of Reference Types.

A value type may not contain NULL values. Reference types
may contain NULL values.

It is not possible to derive new types from Value Types.
This is possible in Reference types. However, Value Types
like Structures can implement interfaces.

Is This Answer Correct ?    2 Yes 2 No

What is the Difference between value and reference type?..

Answer / rita ghosal

REFERENCE TYPE=In contrast to value types, the value of a reference types is allocated on the heap. Another name for a reference type, that you might be more familiar with, is an object. Reference types stores the reference to the data, unlike value types, that stores the value. To demonstrate the difference between a reference type and a value type, let's look
VALUE TYPE=The value of value types are stored on the managed stack, and can be used directly. This means that the value is stored, and not a reference to the value. This also means that each value type has its own copy of the data. Reference Types on the other hand has a reference to the data, and several variables can reference the same data.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

Why do we need to call CG.SupressFinalize?

0 Answers  


What is the difference between selection and projection?

0 Answers  


Why do we use static methods in c#?

0 Answers  


Is an interface a type c#?

0 Answers  


What is data annotation in c#?

0 Answers  






what is generics? can u explain 5 to 6 examples on generics that covers class,method,structure,list,delegates?

0 Answers   Satyam,


What is uint16?

0 Answers  


What?s the difference between an interface and abstract class?

4 Answers  


How will U encapsulate button trigger event into text_box event of Pressing Enter key?

3 Answers   TCS,


Explain the difference between proc. Sent by val and by sub?

0 Answers  


What is a property in c#?

0 Answers  


What are the types of constructors?

0 Answers  


Categories