Yeah, you basically get it. in
expands to const scope
meaning you cannot change the variable (or anything it points to) and also are not supposed to keep a reference to it anywhere (scope
is not actually implemented in most cases though). Basically, in
is look, don't touch.
out
means the given variable receives a value. It is very similar to ref
- changes to it inside the function are also seen on the outside - with the small difference that out variables are initialized to their normal init value, clearing the value they had before the function was called.
Basically, void foo(out int a) {}
== void foo(ref int a) { a = 0; /* inserted automatically */ }