Samir Bhogayta
What are the fundamental differences between value types and reference types?
By Samir Bhogayta in C# on Jun 25 2016
  • Mukesh Kumar
    Aug, 2017 31

    Value type has fixed size& Reference type has not

    • 0
  • Samir Bhogayta
    Jun, 2016 25

    C# divides types into two categories - value types and reference types. Most of the intrinsic types (e.g. int, char) are value types. Structs are also value types. Reference types include classes, arrays and strings. The basic idea is straightforward - an instance of a value type represents the actual data, whereas an instance of a reference type represents a pointer or reference to the data.The most confusing aspect of this for C++ developers is that C# has predetermined which types are represented as values, and which are represented as references. A C++ developer expects to take responsibility for this decision.For example, in C++ we can do this:int x1 = 3; // x1 is a value on the stack int *x2 = new int(3) // x2 is a pointer to a value on the heapbut in C# there is no control:int x1 = 3; // x1 is a value on the stack int x2 = new int(); x2 = 3; // x2 is also a value on the stack!

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS