A couple of weeks ago, we discussed Value types and Reference types where we said that a reference type points to the value it represents and a value type is the value it represents.
This has implications when we work with the assignment operator because when you assign a reference type and change the content of what it is pointing to, both variables get changed because they are both pointing to the same location in memory. If you do this with a value type, only the one you change sees the change because you are working with a copy.
Continue reading “String and StringBuilder”
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. Continue reading “Value Type vs Reference Type”
Podcast: Play in new window | Download
SQL has long had the ability to specify that a value is NULL even if it is a primitive type, but the only way you could have a NULL value in VB.NET is if you were dealing with an object.
That is, until .NET 2.0
Even though .NET 2.0 has been out for a while, I would bet that few VB.NET programmers know about this new feature because it is one of those things most of us have grown to assume is not possible.
Values must have content–objects don’t. That’s just the way it is.
Continue reading “VB.NET Nullable Types”