Thursday, October 4, 2018

what are stack,heap,value, reference types, boxing and unboxing in asp.net c#


Stack :-    stack and heap are memory type in asp.net. Stack is used to        stored data type int, Boolean, double.

Ex.  Void MyFunction()
         {
                 Int I = 1; // this will stored in stack.
                 Int a =5; // this will stored in stack.
         }
                

Heap:-      heap memory is used to stored data type like string,object.
Void MyFunction()
                  {
                            Object  obj  = null // this will stored in heap
                 }

Value Type & Reference Type :- Value type contain actual data  while  reference type contain  pointer and the pointer point to the actual data

Diffrence between  Value Type & Reference Type:-

Value type stored in stack and reference type are stored in heap.

Boxing & unboxing  :- when value type move to a  reference type is called boxing and vice-versa is called unboxing.
 

2 comments:

JOIN US ON TELEGRAM