differences between value type and reference type.

2 votes
188 views
Tarun Gautam asked 15-Nov-2017 in programming by Tarun Gautam

differences between value type and reference type.

1 Answer

0 votes
Arti Mishra answered 11-Jul-2018 by Arti Mishra

"Difference between value type and reference type "

  • Value Type:
    Value Types derive from System.ValueType, which is derived from System.Object.
    In other words, you can say that a data type is a value type that holds data value within its own memory space.
    For example, consider the following integer variable
    int  a=80;
    The system stores 10 in the memory allocated for the variable 'a'.
    differences between value type and reference type.

    The following data types are all of the value types:
    •  bool
    • byte
    •  char
    •  decimal
    •  double
    •  enum
    •  float
    •  int
    •  long
    •  sbyte
    • short
    •  struct
    •  uint
    •  ulong
    •  ushort
    Reference Type:
    ReferenceType doesn’t store the value directly. It Stores the address where the value is stored. In other words, you can say that reference type contains a pointer to another memory location that points the address of any variable.
    differences between value type and reference type.