difference between reference and reference type?with example
worlds of difference.
first, a reference type is anything that is contained in the heap as oppose to the stack. These values are also known as primitive vs reference. the easy way to think about it is variables such as int, bool, char are all contained on the stack. String, object, myCustomObject, any other object is contained in the heap, therefore these values are considered a reference type. A reference, is a variable, any one. They are all references. Some of them reference the stack, some reference the heap.
my guess this came up with you did an "as". Like when you do myVar as int, which wont work because you can't recast values on the stack. It is saying you want to interrupt the value at that reference as a stack type, but that doesn't make sense. You can only re-interupt that which is in memory (not on the stack). That is why you must cast (int) myVar.
Another way to think about is that a value on the stack is never null. You can't reference "null" when it points to the stack, the stack has no null address. But when pointing to memory, there is a valid null location, memory location 0. So if you try to cast something using "as", it will fail because it wants to return null if it isnt correct, and therefore you cannot have a null stack reference (int refereces to the stack).
so to recap:
referenced type is any type held in the heap as oppose to the stack.
a referenced is any variable as it "references " data.