>>1
About passing value type arguments and passing by reference?
It's not exactly about "value types" in particular.
Say you have a variable
x. If it's value type it holds the value itself, otherwise it holds a reference to the value.
Normally the contents of the variable are passed to a function, be that a value or a reference. In other words, you have your variable
x outside of a function, and an argument
y inside the function, and these two are different things, despite having the same value when function is called. If you then change the value of
y, the value of
x doesn't change (but if both are references to some object and you modify that object through
y, of course you will see the changes through
x too)
When you pass it as "ref x", the reference to the variable itself is passed, transparently. So your argument
y is the same thing as your variable
x, and whenever you assign something to
y inside the function,
x changes too.
"out" is exactly the same thing implementation-wise, but additionally means that the function is supposed to initialize the variable. So you don't get a compiler error when you pass an uninitialized variable to the function, and do get a compiler error when you try to use the passed value inside a function.
You might also want to read and about pointers:
http://en.wikipedia.org/wiki/Pointer_(computing), understanding them would allow you to see how references actually work, rather than treating it as some arbitrary magic.