[dba-VB] DotNet passing by value

John W. Colby jwcolby at colbyconsulting.com
Fri Aug 26 06:10:30 CDT 2005


As you might be aware, VB.Net (and I assume the other .net languages as
well) pass all variables by value.  But what does this mean, and is it true.
As you know, everything in .net is an object, even common variables such as
an integer or decimal etc.  Passing by value (in other languages) means
placing a COPY of the variable (or object in this case) on the stack as the
function is called.  In VBA for example, when you pass by value, it really
does ONLY for the simple data types, passing anything else (including
strings) by value.  

Imagine passing a string, which could be a million bytes, by value -
literally making a copy and passing that into the stack.  IIRC the total
stack space for a given program in an Intel machine is something like 128
kbytes which means that passing a single (huge) string by value could cause
a stack overflow.  Now DotNet comes along claiming to pass everything by
value.  Is this more doublespeak?  And if so, what is the truth?

John W. Colby
www.ColbyConsulting.com 

Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/





More information about the dba-VB mailing list