What is difference between value and reference types?
Answers were Sorted based on User's Feedback
Answer / payal
value
this stored actual value
reference
stored the address of the value
value store in stack
reference is stored in heap
the variable which are value type they each time create
their own copy
the variable which are reference type they refer the same
object every time
Is This Answer Correct ? | 5 Yes | 1 No |
Value types allocates the values in stack
Reference types allocates the value references in Heap
Is This Answer Correct ? | 5 Yes | 2 No |
Answer / surya
Value Type holds the data within this own memory allocation.
where as Reference Type contains a pointer to another
memory location that holds the data.
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / shiva charan
Moreover added to the above points
if two reference variables are pointing to the same
location, change in one reference variable will reflect the
other referenc variable.
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / kartheeksirangipatel
ValueType:
-->Value types holds data directly.
-->Nodefault value for valuetype
-->valuetype stored in stack memory
-->Stack is not accessible to Garbage collector
Ex--->Predefined datatypes
Structures
Enumarator
Reference type:
-->Ref type does not holds the datadirectly
-->Ref type holds the default value
-->ref type will be stored in Heap memory
-->Heap is accessible to garbage collector
Ex--->Arryas
Classes
Objects
Deligates
Interfaces
Is This Answer Correct ? | 2 Yes | 2 No |
Advantages of c# over vb.net?
What is join in c#?
Which of the following operations can you not perform on an ado.net dataset?
What is default access specifier for class in c#?
Which types of inheritances does c# support?
You have got 1 million parking slots. At a time a parking slot can be free or not. To get next slot easily which data structure to implement?
What is hashset c#?
What is Named parameter in C#?
How many types of constructor are there in c#?
What is an assembly in dotnet?
Can we have the method in drived class with the same name which is there in base class?
Can you inherit from a static class in c#?