r/visualbasic • u/CurryPudding • Aug 18 '20
[Noob] Does variable in Vb.net have concept of address?
Im doing my assignment on Vb net, I've been searching on the internet and books, but I can't seem to find anything related to the variable address. I found a question similar to mine in Stack Overflow. Someone replied
we dont. so we cant
in dotnet and java world, the concept of address of a variable is not the same as in C. the way address-of-a-variable is taught is old. the java/dot-net languages are way too advanced. of course the variable exists in memory but the address may not be what you think. so while working in these languages we do not usually consider the address aspect. that is considered only in context of C/C++.
Does this mean Vb net dont have the concept? If so, where does it store the variable?
1
u/DystarPlays Aug 18 '20
If you are talking about addresses in memory then yes, but no. All data is stored in memory, and all computers use addresses to know where in the memory that data is stored. Whether a language gives access to manipulating those addresses is the issue.
We talk of programming languages as being "High-Level", or "Low-Level" which refers to how much abstraction there is between what you write and how the computer interprets those instructions. These levels aren't a binary designation, but are comparative (C is lower level than C++), and scalar (C is High-Level but on the lower end of High-Level).
The lower level a language is, the more likely it is to give direct access to memory addresses. VB is relatively High-Level and one of the reasons it falls into this category is because it doesn't give access to memory addresses
1
7
u/clarinetJWD Aug 18 '20
I believe you're talking about pointers. VB.net doesn't have full pointers, but you can get similar functionality by using "ByRef" if it's a parameter to a method.
For simple variables, primitive types (Integer, Char, Double, etc) are always by value. Objects like classes are always by reference (a pointer to the actual object)
For example:
But take the following class:
It works like this:
Lastly, take the following method example:
Excuse any formatting issues... I'm on mobile.