Value Type vs Reference Type
TRACK

Value Type vs Reference Type

Avatar

It is amazing to me how few programmers understand the fundamentals of how variables work.  Not just in .NET or C# specifically, but in every language they work in.  It amazes me for two reasons.  First, I don’t think I could program if I didn’t understand what was physically happening as a result of the code I was writing.  Not knowing how the variables relate to the memory that they use would be, to me, a major limitation.  But it also amazes me because I don’t think anyone can program intelligently until they do know what is happening.
So, I’ll start from the outside and move in to what’s happening in memory.
What is A Value Type
The first question we need to qualify is, “What types in .NET are referred to as Value types?  Common value types are int, double, float, decimal, and bool.  What we ypically refer to as “primitives”.  But, there are other types that are also value types.  Enums, structs, and DateTime(because it is a struct) are also value types.
What is a Reference Type
Re

Comments

Avatar