vinod kumar 0
what is the difference between reference type and value type?
By vinod kumar 0 in ASP.NET on Mar 04 2009
  • naininaveen kumar
    Mar, 2009 6

    value type : storage will be on stack memory

    Reference type: storage will be on heap memory

     stack memory will be allocated  by the compiler towards an application ,this

    doesn't supprt dynamic creation and destruction.

    It is recommended for string small amount of data for faster access.

    Runtime will be allocate heap memory.This will support dynamic allocation and destruction.

    This memory supports hiearchial representation of data i.e inheritance process.

    This memory is recommended for large storage of data.

     

    • 0
  • P Narasimha
    Mar, 2009 6

    Value type :Value type is Nothing but it can store the Values in Stack Memory .
    ex: int a = 100;
    here a =100 valu can store in Stack memory.
    Value type Does not Allowed null values.
    structure is value type ,int,byte,enum etc.
    Referece Type :Referece Type is Nothin But stord the value in Heap memory.
    Ex:public  class A
    {
    public void Hi()
    {
    Console.WriteLine("Hi How r u");
    }
    }
    public static void main()
    {
    A a= new A();//here "a" refferece values is stor in Heap Memory.
    a.hi();
    }
    }
    Reference type  will be Allowed Null values.
    ex:class,Object,interface etc.

    • 0
  • Vinod Rao Vutpala
    Mar, 2009 5

    Differences between Value types and Reference types:

    Value type holds the data directly
    Reference type points to the location that holds the data.


    Examples of value type variables:  byte, decimal, float, int, structs
    Examples of reference type variables: string, class, delegate, interface


    Value type cannot contain null value
    Reference type can contain null value.


    Value type variables are stored on stack.
    Reference type
    variables are stored on heap.

    A new type cannot be derived from value type.
    A new type can be derived from reference type.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS