Daily Archives: 06/04/2018

Reference types and value types in .NET

Published by:

Note: I also made a YouTube video on this topic with some more graphical representations of these concepts. You might want to check it out: https://www.youtube.com/watch?v=8Uf-ziPWbJQ

In .NET (and therefore C#) there are two main sorts of type: reference types and value types! Understanding these sorts of type is crucial in the .Net ecosystem and, more generally, in object oriented programming. There are some clear definitions of these concepts that anybody could learn fairly easy, but really understanding how reference types and value types work is sometimes a little bit harder. And I must confess that it took me some time to achieve a certain level of familiarity. Furthermore, if you really want to understand how reference types and value types work, you need to get your hands dirty an play around with them. In this article I will try to explain reference types and value types as good as I can, starting from some dry (but important) definitions that I will try to make more vivid using code samples. Continue reading